boost.asio async_write/read_until guarantee
Hi, 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? If it's not guaranteed can anyone think of a solution to create such a guarantee in my own program? (I posted the same question on the asio mailinglist but i assume there's more activity here) Thanks in advance -- Mierswa, Daniel If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do. --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
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
participants (2)
-
Daniel Mierswa
-
dizzy