Re: [asio-users] strand - first call to dispatch() queues it
Brought to you by:
chris_kohlhoff
From: Christopher K. <ch...@ko...> - 2008-05-30 00:09:26
|
Andrey Tcherepanov wrote: > Thanks Christopher. > > So, if I have one socket that I issue 3 write ops on it, how can I be sure > that they are > > a. not overlapping (second did not start till first is not finished > completely) Don't issue the second one until the first one is finished, and ... > b. ordered by any way? ... issue them in the order you want them to be sent :) > Say, if I have a code that has 3 async_writes one > by one in one function, may I assume that they will be executed as they > are called? Would _really_ clean up some of my code, when I could pipeline > write requests from different places/threads just by issueing them :) A composed function such as async_write, which is implemented in terms of multiple calls to the async_write_some member function, cannot be performed at the same time as another async_write. If you do, you could end up with interleaved writes. You'll need to build your own pipeline, as in the chat example's client. You *can* have multiple outstanding async_read_some or async_write_some operations on a single socket, but in the case of async_write_some whether that does something meaningful is platform and transport dependent. Cheers, Chris |