|
Boost Users : |
Subject: Re: [Boost-users] [asio] is the io_context queue FIFO?
From: Gavin Lambert (boost_at_[hidden])
Date: 2018-09-17 23:24:19
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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net