Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.asio] Is it safe to call write() and async_read at the same time?
From: Frank (fhriley_at_[hidden])
Date: 2011-05-12 11:02:56


On Thu, May 12, 2011 at 12:52 AM, Igor R <boost.lists_at_[hidden]> wrote:
> I mean that ASIO documentation states explicitly:
> <<Thread Safety:
> Distinct objects: Safe.
> Shared objects: Unsafe>>
> http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/reference/ip__tcp/socket.html

This is "the standard answer", but in my opinion, it's not good
enough. The revision history for asio version 1.4.0 states the
following:

"Synchronous read, write, accept and connect operations are now thread
safe (meaning that it is now permitted to perform concurrent
synchronous operations on an individual socket, if supported by the
OS)."

So clearly, the "Shared objects: Unsafe" does not tell the whole
story. I also have yet to see an example where async_read/write's that
could be could called simultaneously are surrounded by mutexes. It
would be really nice to get a clear answer on whether these methods
are thread safe or not.


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