wwa-coro 0.0.1
Yet Another C++20 Coroutine Library
run_awaitable.cpp

Shows how to use run_awaitable to turn any awaitable into an eager coroutine that runs synchronously from the caller's perspective.

#include <iostream>
#include "eager_task.h"
#include "task.h"
namespace {
wwa::coro::task<int> async_increment(int v)
{
co_return v + 1;
}
wwa::coro::task<> display(int v)
{
auto result = co_await async_increment(v);
std::cout << "Result: " << result << "\n";
}
} // namespace
int main()
{
// Expected output:
// Result: 3
return 0;
}
A coroutine task.
Definition task.h:196
Eager coroutine.
eager_task run_awaitable(Awaitable &&f, Args &&... args)
Turns any awaitable into an eager fire-and-forget coroutine.
Definition eager_task.h:130
Coroutine-based task.