|
Boost Users : |
From: dizzy (dizzy_at_[hidden])
Date: 2008-08-20 04:09:54
On Tuesday 19 August 2008 18:45:39 Daniel Mierswa wrote:
> Hi,
Hello
> if i have a threadpool running an io_service and a read_until is invoked
> before async_write. Now i wonder what would happen if the string is
> written to the socket, will the write handler be called before the
> read_handler or is it undefined in which order they will be invoked?
Unspecified order because it largely depends on:
- OS specifics like TCP input/output buffer sizes and message size sent/read
- asio implementation details
> If
> it's not guaranteed can anyone think of a solution to create such a
> guarantee in my own program?
But once your read handler is called there is no more read operation on the
socket until you do another async_read in the handler (or other code). So no
read handler will be called. Just do an async_write in the read handler
without any async_read, wait for the write handler to be called and there you
use async_read to manifest interest in reading again. Thus no read handler
will be called until the write handler is called where you do the async_read.
-- Dizzy "Linux is obsolete" -- AST
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