cobalt icon indicating copy to clipboard operation
cobalt copied to clipboard

Request, create empty promise object that can be set later outside of a coroutine.

Open sandercm opened this issue 1 year ago • 1 comments

Hi,

I was wondering if it would be possible to add a method that would set a coroutine object from the "outside". For example

boost::cobalt::promise<std::string> request;
// save the promise somewhere in a data struct
// ....
// recieve some network data
// match it with a request
request.set(data);

this would then resume any coroutine that is currently co_awaited on this promise. I found a way around this by using async channels but was wondering if it would be at all possible to do this without them?

sandercm avatar Sep 23 '24 09:09 sandercm

It is not, that's what channels are for.

klemens-morgenstern avatar Sep 24 '24 13:09 klemens-morgenstern