Merged
Conversation
58aab2d to
05b7c45
Compare
05b7c45 to
7e9a2cd
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ended up being a moderately significant reconsideration of how timers run down.
The windows thread pool has some fun oddities in how it synchronizes with cancellation / finalization of potentially concurrent dispatch of the events for shutdown. These are understandable but were not really handled in the original design in a way that was usable.
The API is now more straightforward, although the current implementation does encapsulate the Windows oddity that at shutdown of a timer, a wait for the possibly in flight event to complete must happen. That wait has no timeouts and is not interruptible. See CloseThreadPoolTimer in the Microsoft Win32 API documentation for more details.
There is another alternative to this which is to have the timer object be a front for another reference counted object, as Raymond Chen describes in this post. I didn't choose this approach for three reasons:
In the end, it seemed like adding the level of indirection was just putting off the disaster a little bit, and there are still issues about ensuring that the code (as in the DLL in the case of Windows) stays mapped during the possible callback duration.
Thus, I elected to not pursue the more complex solution since it seems to open a cavern of more issues.