kreuzerkrieg
kreuzerkrieg

Reputation: 3239

boost::asio::basic_waitable_timer `cancel` behavior

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

Answers (1)

sehe
sehe

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

Related Questions