When do I have to use io_service::strand
?
From the documentation it seems that I need it when I want to prevent several handlers to be executed concurrently:
The io_service::strand class provides the ability to post and dispatch handlers with the guarantee that none of those handlers will execute concurrently
As far as I know, this can happen if I have several threads calling run
on the same io_service
object.
So, from this point of view, it seems that the only reasonable way to use strand
is when we have some shared memory inside our handlers passed to the io_service::post
function and we don't want to use any synchronization primitives like boost::mutex
inside them for some reason. Am I right?
Or is there any internal io_service
problems with having two threads calling io_service::run
concurrently?