Reputation: 3239
Assume there is asio
's deadline_timer
or similar, it expires and the callback is invoked. During the invocation and while the callback is still running the cancel
is called.
The question is the cancel
gonna block until the callback finishes?
Upvotes: 2
Views: 574
Reputation: 393769
No, cancel doesn't block and also doesn't wait for any handlers to have completed.
It is your responsibility to synchronize access to the timer instance if access is from different threads.
The limited threadsafety is documented here: https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/reference/basic_waitable_timer.html#boost_asio.reference.basic_waitable_timer.thread_safety
Upvotes: 1