Skip to content

How to integrate coroutines with an existing framework? #24657

Closed Answered by rthrfrd
rthrfrd asked this question in Q&A
Discussion options

You must be logged in to vote

Ok this works: It's basically a reimplementation of val::awaiter + emval_coro_suspend, without being restricted to either val::promise_type or val::awaiter respectively. It binds itself to the promise that you're going to await just the same. No doubt it is less terse/efficient but I'm pretty likely to forget how this works so verbosity it is!

Probably has issues I only just got it working, exception path not tried yet, but the principle stands to allow interop with other coroutine frameworks.

struct GlueReceiver {
    enum class Status {
        PENDING = 0x0,
        RESOLVED,
        REJECTED,
    };

    Status status{Status::PENDING};
    std::optional<std::coroutine_handle<>> handle…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by rthrfrd
Comment options

You must be logged in to vote
1 reply
@rthrfrd
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants