-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add noexcept specifiers where appropriate
We can mark the following as `noexcept`: - ~ScopedConnection - ~Signal - ConnectionHandle::disconnect - several move constructors There are some caveats though: When disconnecting, we need to lock the mutex in the ConnectionEvaluator and allocate in the GenerationalIndexArray, which can both throw exceptions. However, we currently do not have any out of memory guarantees in KDBindings, so terminating in that case should be a sufficient way of handling this case. The same goes for when locking a mutex isn't possible. This likely indicates some kind of OS issue from which we can't really recover, so terminating is appropriate. We could improve the situation by avoiding allocations in the GenerationalIndexArray when erasing slots. This would be possible by using an inline linked-list inside the array to store free indices. Which would save memory and would no longer require us to allocate memory when erasing entries. However, it's also not trivial to implement, so leave this as a TODO. Error checking in ConnectionEvaluator ------------------------------------- This patch also adds some basic exception handling to the ConnectionEvaluator. It is now somewhat protected from slots disconnecting themselves while they are evaluated and slots throwing exceptions. However, this error-handling is rather basic and will simply **not** dequeue any slots while the evaluator is already evaluating and will dequeue all slots if any slot throws an exception. We could improve this situation by using a queue and popping elements 1-by-1 when evaluating without actually iterating over it. That way we could erase from the queue while its being evaluated. And when a slot throws, calling evaluate again could simply continue with the next slot, instead of skipping all queued slots. However, we should ideally implement this queue as a ring-buffer to avoid excessive allocations by std::list or std::dequeu. But this isn't part of the STL, so would require us to roll our own ring-buffer implementation. For now, this error handling isn't publicly documented and throwing within a slot or dequeuing while evaluating remains *undefined*, so that we can improve the situation in the future.
- Loading branch information
1 parent
17de31c
commit 1aec52e
Showing
4 changed files
with
125 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters