If your implementation is single threaded, you don't need to worry about
concurrency issues at all. All completion handlers will be scheduled to run
sequentially.
In other words, no need for a mutex.
If you later decide to make your program multi-threaded (i.e. multiple
threads per io_context) then the idiomatic method to control concurrency is
to use an asio::strandasio::any_io_executor as your executor type for
each io_enabled concern (such as a connection).
In asio, (and net.ts) the strand is a special executor adapter that
guarantees that although multiple completion handlers can execute
concurrently through the *underlying executor*, they can only complete
*sequentially* through the strand which is *adapting* that underlying
executor.
On Mon, 7 Sep 2020 at 11:54, Jupiter via Boost
Hi,
I used boost::asio::io_service for a single thread implementation but with multiple boost::asio::deadline_timer objects, because it is a single thread, I don't think I need to use boost::mutex to lock and unlock tasks running by deadline_timer, am I wrong about it?
Thank you.
Kind regards,
jupiter
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Richard Hodges hodges.r@gmail.com office: +442032898513 home: +376841522 mobile: +376380212