File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 3030#include < boost/asio/spawn.hpp>
3131#include < boost/asio/steady_timer.hpp>
3232#include < boost/asio/strand.hpp>
33- #include < boost/asio/use_future.hpp>
3433
3534#include < atomic>
3635#include < chrono>
@@ -96,7 +95,12 @@ class RepeatedTask {
9695 if (auto expected = State::Running; not state_.compare_exchange_strong (expected, State::Stopped))
9796 return ; // Already stopped or not started
9897
99- boost::asio::spawn (strand_, [this ](auto &&) { timer_.cancel (); }, boost::asio::use_future).wait ();
98+ std::binary_semaphore cancelSemaphore{0 };
99+ boost::asio::post (strand_, [this , &cancelSemaphore]() {
100+ timer_.cancel ();
101+ cancelSemaphore.release ();
102+ });
103+ cancelSemaphore.acquire ();
100104 semaphore_.acquire ();
101105 }
102106};
You can’t perform that action at this time.
0 commit comments