[asio] is the io_context queue FIFO?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[asio] is the io_context queue FIFO?

Boost - Users mailing list
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().

Thanks,

F
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [asio] is the io_context queue FIFO?

Boost - Users mailing list
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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [asio] is the io_context queue FIFO?

Boost - Users mailing list
Hi,

Thanks for you message.

> I'm not sure about the Linux implementation; there are a couple of
> different options there IIRC.

could you give me a hint on where I can find those options?

Kind regards,

F
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [asio] is the io_context queue FIFO?

Boost - Users mailing list
On 18/09/2018 19:12, Frédéric wrote:
>> I'm not sure about the Linux implementation; there are a couple of
>> different options there IIRC.
>
> could you give me a hint on where I can find those options?

It defaults to using the best (most reliable and performant) option for
your platform, so it's usually best not to mess with it.

But if you really want, you can #define things to tell it to use a
different backend.  See:
   https://www.boost.org/doc/libs/1_68_0/doc/html/boost_asio/using.html
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [asio] is the io_context queue FIFO?

Boost - Users mailing list
In reply to this post by Boost - Users mailing list


On Mon, 17 Sep 2018 at 14:08, Frédéric via Boost-users <[hidden email]> 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().

The asio documentation provides no guarantee of execution order at all, other than the execution of a dispatched function happens before the dispatch call returns.

From memory, previous versions of ASIO used to provide some guarantees around this, but since the current documentation does not mention it, one must assume that it's unknowable and code accordingly.


 

Thanks,

F
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [asio] is the io_context queue FIFO?

Boost - Users mailing list
> The asio documentation provides no guarantee of execution order at all, other than the execution of a dispatched function happens before the dispatch call returns.> From memory, previous versions of ASIO used to provide some guarantees around this, but since the current documentation does not mention it, one must assume that it's unknowable and code accordingly.

thanks,

F
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users