wwa-coro
0.0.1
Yet Another C++20 Coroutine Library
src
eager_task.h
Go to the documentation of this file.
1
#ifndef CF9BADEE_8060_4165_91B2_54C840903F88
2
#define CF9BADEE_8060_4165_91B2_54C840903F88
3
14
15
#include <coroutine>
16
#include <exception>
17
#include <functional>
18
19
namespace
wwa::coro
{
20
21
// NOLINTBEGIN(readability-convert-member-functions-to-static)
32
class
eager_task
{
33
public
:
42
struct
promise_type
{
44
53
[[nodiscard]]
constexpr
auto
get_return_object()
const
{
return
eager_task
{}; }
54
64
[[noreturn]]
void
unhandled_exception()
const
noexcept
{ std::terminate(); }
65
74
constexpr
void
return_void()
const
noexcept
{}
75
88
[[nodiscard]]
constexpr
auto
initial_suspend()
const
noexcept
{
return
std::suspend_never{}; }
89
102
[[nodiscard]]
constexpr
auto
final_suspend()
const
noexcept
{
return
std::suspend_never{}; }
103
105
};
106
};
107
// NOLINTEND(readability-convert-member-functions-to-static)
108
113
128
template
<
typename
Awaitable,
typename
... Args>
129
// NOLINTNEXTLINE(cppcoreguidelines-avoid-reference-coroutine-parameters)
130
eager_task
run_awaitable
(Awaitable&& f, Args&&... args)
131
{
132
co_await
std::invoke(std::forward<Awaitable>(f), std::forward<Args>(args)...);
133
}
134
139
140
}
// namespace wwa::coro
141
142
#endif
/* CF9BADEE_8060_4165_91B2_54C840903F88 */
wwa::coro::eager_task
Eager coroutine.
Definition
eager_task.h:32
wwa::coro
Library namespace.
Definition
async_generator.h:31
wwa::coro::run_awaitable
eager_task run_awaitable(Awaitable &&f, Args &&... args)
Turns any awaitable into an eager fire-and-forget coroutine.
Definition
eager_task.h:130
wwa::coro::eager_task::promise_type
The promise type for the eager_task coroutine.
Definition
eager_task.h:42
Generated by
1.13.2