In my understanding, posting handlers to a strand
object means:
Posting handlers directly to an io_service
object and wrapping them by strand::wrap
also means that only one of the posted handlers is executed at a time, but not in order.
Is there any other difference? And how can I run two (or more) different kind of works (so, different handlers/functions) parallel (in different threads) by using strand
?
If you want them to run in parallel don't use stands. Strands are for serializing. Just post to the service and have the service run in a thread pool.
But you bring up a good point that I would like someone to answer. What exactly is the difference? If wrap serializes all handlers then how could they get out of order, i.e. seems like it does the same thing as posting through a strand? Where would you use one over the other?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With