Function operator co_await

Summary

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

(1) auto operator co_await() const &noexcept

(2) auto operator co_await() const &&noexcept

Function overload

Synopsis

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

auto operator co_await() const &noexcept

Description

No description yet.

Source

Lines 187-214 in lib/inc/drogon/utils/coroutine.h.

auto operator co_await() const &noexcept
{
    struct awaiter
    {
      public:
        explicit awaiter(handle_type coro) : coro_(coro)
        {
        }
        bool await_ready() noexcept
        {
            return !coro_ || coro_.done();
        }
        auto await_suspend(std::coroutine_handle<> handle) noexcept
        {
            coro_.promise().setContinuation(handle);
            return coro_;
        }
        T await_resume()
        {
            auto &&v = coro_.promise().result();
            return v;
        }
      private:
        handle_type coro_;
    };
    return awaiter(coro_);
}

Synopsis

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

auto operator co_await() const &&noexcept

Description

No description yet.

Source

Lines 216-242 in lib/inc/drogon/utils/coroutine.h.

auto operator co_await() const &&noexcept
{
    struct awaiter
    {
      public:
        explicit awaiter(handle_type coro) : coro_(coro)
        {
        }
        bool await_ready() noexcept
        {
            return !coro_ || coro_.done();
        }
        auto await_suspend(std::coroutine_handle<> handle) noexcept
        {
            coro_.promise().setContinuation(handle);
            return coro_;
        }
        T await_resume()
        {
            return std::move(coro_.promise().result());
        }
      private:
        handle_type coro_;
    };
    return awaiter(coro_);
}





Add Discussion as Guest

Log in