wwa-coro 0.0.1
Yet Another C++20 Coroutine Library
task.h File Reference

Coroutine-based task. More...

#include <cassert>
#include <coroutine>
#include <exception>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include "detail.h"
#include "exceptions.h"
+ Include dependency graph for task.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  wwa::coro::task< Result >
 A coroutine task. More...
 

Namespaces

namespace  wwa
 
namespace  wwa::coro
 Library namespace.
 

Detailed Description

Coroutine-based task.

This file contains the definition of a coroutine-based task class template. The task class allows for the creation of coroutine-based tasks that produce values of a specified type. It provides an interface for handling asynchronous operations and managing the state of the coroutine.

Example:

{
co_return 123;
}
{
co_return 456;
}
{
const auto a = co_await task1();
const auto b = co_await task2();
co_return a + b;
}
{
std::cout << "The result is " << co_await sum() << "\n";
}

Definition in file task.h.