
Is it legal to mix async and sync function calls? (I was not able to find the answer in the doc.) E.g. socket.async_read_some(buf); socket.write_some(otherbuf); Also when in a blocking sync call, will it be possible to "cancel" it from another thread, e.g. by posting to the io_service which will invoke a close on the socket? Thank you in advance. -- _________________________________________ _ _ | Roland Schwarz aka. speedsnail |_)(_ | sip:speedsnail@ekiga.net | \__) | mailto:roland.schwarz@chello.at ________| http://www.blackspace.at

On Thu, 17 Sep 2009 09:11 +0200, "Roland Schwarz" <roland.schwarz@chello.at> wrote:
Is it legal to mix async and sync function calls? (I was not able to find the answer in the doc.)
E.g.
socket.async_read_some(buf); socket.write_some(otherbuf);
Yes. Some examples use this (e.g. porthopper). Do make sure you respect the documented thread safety requirements though (i.e. don't do the above function calls concurrently).
Also when in a blocking sync call, will it be possible to "cancel" it from another thread, e.g. by posting to the io_service which will invoke a close on the socket?
No. Only async calls can be portably cancelled. Cheers, Chris

Christopher Kohlhoff wrote:
On Thu, 17 Sep 2009 09:11 +0200, "Roland Schwarz" <roland.schwarz@chello.at> wrote:
Also when in a blocking sync call, will it be possible to "cancel" it from another thread, e.g. by posting to the io_service which will invoke a close on the socket?
No. Only async calls can be portably cancelled.
This is interesting. I thought asio was using overlapped io for the blocking calls also. (If not how, would it be possible then to handle the pending async calls in the background?) And when using overlapped for the blocking calls why wouldn't it be possible then to use the same cancelling mechanism? Yet another question: Are you considering to add async file IO to this great library? Thank you, Roland -- _________________________________________ _ _ | Roland Schwarz aka. speedsnail |_)(_ | sip:speedsnail@ekiga.net | \__) | mailto:roland.schwarz@chello.at ________| http://www.blackspace.at
participants (2)
-
Christopher Kohlhoff
-
Roland Schwarz