Re: [Boost-bugs] [Boost C++ Libraries] #10009: Boost Asio should provide also thread-safe sockets

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10009: Boost Asio should provide also thread-safe sockets
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-12-01 09:09:52


#10009: Boost Asio should provide also thread-safe sockets
---------------------------------------------+----------------------------
  Reporter: Vladislav Valtchev <vladi32@…> | Owner: chris_kohlhoff
      Type: Feature Requests | Status: new
 Milestone: To Be Determined | Component: asio
   Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------+----------------------------

Comment (by anonymous):

 Replying to [comment:1 anonymous]:
> Strands don't make ASIO thread safe by the way. It only makes the
 callbacks thread safe. You still can't read/write from multiple threads,
 even when calling from within a stranded callback. I've made several tests
 to prove this to myself, and like you I am very disappointed and kind of
 baffled.

 If you use always the same strand for a requesting async reads/writes, it
 is thread-safe beacuse the strand itself causes functors wrapped with it
 to execute ''sequentially''. The problem is that you cannot simply issue a
 request from ''outside'' a callback in a thread-safe way: if thread X
 received a WIN32 event for example (with its handler not wrapped by a
 strand of course), and it wants to do an async_read() on socket S, than it
 has necessarily to post in the strand of socket S a functor requesting the
 async_read() and having the callback wrapped with the same strand as well.
 So, the point is that even '''the requests for async operations have to be
 async''', unless they come from code that is ''already executed'' within a
 strand. In practice, that causes a significant re-scheduling overhead and,
 depending from the point of view, less-readable code.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10009#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC