Struct promise_type

Synopsis

#include <lib/inc/drogon/utils/coroutine.h>

template <>
struct promise_type

Description

No description yet.

Methods

final_suspend
get_return_object
initial_suspend
result
return_void
setContinuation
unhandled_exception

Source

Lines 290-322 in lib/inc/drogon/utils/coroutine.h.

struct promise_type
{
    Task<> get_return_object()
    {
        return Task<>{handle_type::from_promise(*this)};
    }
    std::suspend_always initial_suspend()
    {
        return {};
    }
    void return_void()
    {
    }
    auto final_suspend() noexcept
    {
        return final_awaiter{};
    }
    void unhandled_exception()
    {
        exception_ = std::current_exception();
    }
    void result()
    {
        if (exception_ != nullptr)
            std::rethrow_exception(exception_);
    }
    void setContinuation(std::coroutine_handle<> handle)
    {
        continuation_ = handle;
    }
    std::exception_ptr exception_;
    std::coroutine_handle<> continuation_;
};





Add Discussion as Guest

Log in