Closed systocrat closed 1 year ago
Easiest (and probably best): use an asio::experimental::channel
Alternatively, use any_completion_handler
Channel seems to work great for me, and good shout about any_completion_handler- That'll be useful elsewhere. Cheers!
Hello,
I'd like to write some code that looks like this:
In which I have a data processor that waits for a message from an underlying implementation with its own async functions.
Since I don't have any idea when the next message is coming, and asking for a message doesn't inherently initiate any asynchronous operations, I'd like to store a callback for later. I'd like to be able to pass in any kind of completion token without treating them any differently from one another.
The issue I'm running into is with propagating the handlers that my initiation function in async_initiate is called with. Since I don't know the type of the completion handler at compile time, I can't reasonably store it in a class member.
How should I approach this problem?