Boost Users :
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2019-09-03 14:21:54
my experiments with custom composed operations in asio have led me to
another question regarding the use of such methods.
What do I do in order to have multiple handlers in flight, e.g. for a timer?
My example is here:
I'm trying to realize an old dream in asio. A function that will take a
socket and asynchronously do a resolve and connect to the result while
having a timeout around the operation.
Here in the test cases (lower part) is how I imagine usage:
This works (the unit test does...) but I think it's no good and illustrate
the problem. In the coroutine impl I can safely jump in and out and resume
the code represented by the coroutine object as was explained to me
yesterday. But what can I do with the timer? I cannot std::move(self) into
it because it gets moved again moments later and I cannot yield on the
timer wait operation. I want the timer handler and the async ops handlers
both be in flight and have called whichever completes first.
I tried coroutine fork thinking it might be the right tool but that seems
to clash with the move-self-ahead pattern which is used here.
If I don't yield and set the timer to a fixed lambda (as in the example
above) it seems to work but I guess that's not how it's supposed to be,
Any hints as to how I can make this better?
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