Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-09-22 17:39:51


Niall Douglas wrote:
> But to answer your question more generally, it is quite hard to avoid heap
> allocation for asynchronous *anything*. As Vinnie pointed out, you can't
> move state while something async is occurring. So there are two choices,
> either you use heap allocation or something gives you an opaque handle and
> you store that opaque handle in a map to state, which is probably a heap
> allocation.

Hypothetically, what Andrzej was asking for was: he gives Asio a movable
state object and a movable completion handler, Asio puts these somewhere,
initiates the async op, doesn't move them in the meantime, when the async
op completes invokes the handler, passing it the address of the state object,
the handler then either moves the state back somewhere, or gives it back
to Asio for the next async call.

This looks doable, although in practice probably won't gain much.


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