#coroutine callback

2 messages · Page 1 of 1 (latest)

boreal nymph
#

I am wondering if it's possible to update a callback function to use coroutines. I am using c++20 with MSVC 2019 amd64 16.10. I have a thirdparty C library that registers a callback and I'd like the callback function to get the value and free the caller's thread. I think a coroutine would help here but if a different strategy would be better then I'm all ears.

Code: https://godbolt.org/z/T365MaT8z
Expected: register a callback function and use co_await to wait for the callback to be triggered, get the value
Problem: trying to grasp coroutines and I'm not sure I'm returning the value from the promise_type

hoary sequoiaBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.