On 18/09/2018 01:07, Frédéric wrote:
Is there a guarantee that the events posted using boost::asio::post() are called in the order of submission or can they be called in any order? Note that I have multiple threads running io_context.run().
On Windows it's implemented using an I/O Completion Port, which is internally a FIFO queue. I'm not sure about the Linux implementation; there are a couple of different options there IIRC. In any case, once you have multiple consuming threads using the same queue it becomes a little harder to define what FIFO truly means, since one thread might be able to execute tasks 2 and 3 faster than another thread executes task 1. There are also other considerations, such as whether dispatch, defer, or post is used to queue up subsequent work. Typically if the order matters to you, you should enforce this by not starting operation 2 until operation 1 completes, and so forth.