Implementation of a promise/future system for coroutines. More...
#include <coroutine>
#include <optional>
#include <variant>
#include <memory>
#include <functional>
#include "promises.hpp"
#include "poller.hpp"
Go to the source code of this file.
Classes | |
struct | NNet::TPromiseBase< T > |
Base promise type for coroutines. More... | |
struct | NNet::TPromise< T > |
Promise for coroutines that return a value of type T. More... | |
struct | NNet::TFutureBase< T > |
Base future type for coroutines. More... | |
struct | NNet::TFuture< T > |
Future type for coroutines returning a value of type T. More... | |
struct | NNet::TPromise< void > |
Promise specialization for coroutines that return void. More... | |
struct | NNet::TFuture< void > |
Future specialization for coroutines that return void. More... | |
struct | NNet::TFinalAwaiter< T > |
Final awaiter for a coroutine. More... | |
Functions | |
template<typename T> | |
TFuture< std::vector< T > > | NNet::All (std::vector< TFuture< T > > &&futures) |
Awaits the completion of all futures and collects their results. | |
TFuture< void > | NNet::All (std::vector< TFuture< void > > &&futures) |
Awaits the completion of all void-returning coroutines. | |
template<typename T> | |
TFuture< T > | NNet::Any (std::vector< TFuture< T > > &&futures) |
Awaits the completion of any one of the given futures and returns its result. | |
TFuture< void > | NNet::Any (std::vector< TFuture< void > > &&futures) |
Awaits the completion of any one of the void-returning coroutines. | |
Implementation of a promise/future system for coroutines.
This file defines the promise and future types used to manage coroutine execution. It provides mechanisms to retrieve coroutine results (or exceptions) and to coordinate multiple asynchronous operations.
TFuture< std::vector< T > > NNet::All | ( | std::vector< TFuture< T > > && | futures | ) |
Awaits the completion of all futures and collects their results.
T | The type of each coroutine's result. |
futures | A vector of TFuture<T> objects. |
|
inline |
Awaits the completion of all void-returning coroutines.
futures | A vector of TFuture<void> objects. |
TFuture< T > NNet::Any | ( | std::vector< TFuture< T > > && | futures | ) |
Awaits the completion of any one of the given futures and returns its result.
If one of the futures has already finished, its result is returned immediately. Otherwise, the current coroutine is suspended until one of the futures completes.
T | The type of the coroutine's result. |
futures | A vector of TFuture<T> objects. |
|
inline |
Awaits the completion of any one of the void-returning coroutines.
futures | A vector of TFuture<void> objects. |