Boost logo

Boost :

Subject: Re: [boost] [asio] Mixing of sync and async calls
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2009-09-19 19:04:26


On Thu, 17 Sep 2009 09:11 +0200, "Roland Schwarz"
<roland.schwarz_at_[hidden]> 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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk