-
Notifications
You must be signed in to change notification settings - Fork 422
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
Avoid timers to be executed twice in the multithreaded executor #1328
Conversation
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
e78b165
to
fb80881
Compare
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.
But this breaks the Timer so that it cannot be run concurrently in a reentrant callback group with a multi-threaded executor. I think we're just trading one broken thing for another.
I wouldn't consider that a bug, at most I would consider it a non optimal approach to the problem. Though really, I'm not sure if allowing to execute timer callbacks reentrantly is a good idea at all, but maybe it is (?). On the other hand, #1487 is definitely buggy behavior. But yes this PR isn't really "the right fix" as you can actually block another worker thread that took the same timer (ideally, if we would consider that reentrant execution of the same executable is not a good idea, a worker thread would never take the same executable than another and thus it wouldn't be blocked), but I don't see an easy solution here without major surgery of the executor code (and I'm not sure what that would be). |
we cannot expect how long user callback takes. if user callback takes 5 seconds and if other threads are scheduled to execute the same timer (I think this is probable), these threads will be blocked for 5 seconds just waiting on the |
This is exactly the reason I came up with callback groups originally, because otherwise, when using a multi-threaded executor, the user would always have to synchronize their callbacks and that would lead to most threads in the pool just waiting on one of those mutexs, even though other things could be done. |
Alternatively #1516 also fixes the issue. |
Closing in favor of #1516 |
Fixes #1374 by adding a mutex inTimer
class, that makesis_ready
andexecute
methods mutually exclusive.Fixes #1487.
It deletes the old "scheduled timers" mechanism, that has a long history of being error prone.