-
Notifications
You must be signed in to change notification settings - Fork 276
Event watchers might want to be passive #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I don't think this works. If the watcher is passive, then it will just fire continuously because nobody is resetting the event. |
The issue is because a user-owned process wanted to react to a doorknock auto-reset event owned by a service. The service handed out a SYNCHRONIZE-rights handle (or it was opened by name and had an ACL on it, I don't remember.) Attempting to ResetEvent from the process failed and failfasted. For watcher-owned events, I agree that reset-and-rearm is likely correct. For events the watcher is asked to watch, it seems like a flag to control "should you reset" and "should you rearm" might be good. I had a version of this that exposed both "reset the event" and "rearm the wait" ... that variant would need a way to request that the watcher rearm. What do you think? |
|
Two comments:
|
| is_base_of<typename remove_reference<_T2>::type, _T1>::value)) | ||
| #endif | ||
| >{}; | ||
| > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this to address a compiler issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based off changes elsewhere, it looks like Jon just ran clang-format on whole source files
Ah, I see. This is basically "Is this a manual-reset event or an auto-reset event that I'm watching?" If it's a manual-reset event, then I have to reset it myself. If it's an auto-reset event, then I should allow the wait completion do the reset. So maybe the flag is enum class event_watcher_options
{
is_auto_reset_event = 0x0, // allow the wait completion to reset the event automatically
is_manual_reset_event = 0x1, // Reset the event during the watch callback
};And if we also want to have the re-arm flag in there enum class event_watcher_flags
{
none = 0x0,
manual_reset = 0x1,
single_shot = 0x2, // or "one_time"
};
DECLARE_ENUM_FLAG_NONSENSE(event_watcher_flags); |
Some watchers only want to ... watch? Allow passing a flag down to control whether an event watcher calls
ResetEventduring its callback. The default is still "yes, reset" so existing code compiles and works the same.This fixes #482