COROIO: NNet::TFuture< T, TEagerFuturePolicy > Struct Template Reference
COROIO
Loading...
Searching...
No Matches
NNet::TFuture< T, TEagerFuturePolicy > Struct Template Reference

Owned coroutine handle that carries a result of type T. More...

#include <corochain.hpp>

Inheritance diagram for NNet::TFuture< T, TEagerFuturePolicy >:
NNet::TFutureBase< T >

Public Member Functions

T await_resume ()
template<typename Func>
auto Apply (Func func) -> TFuture< decltype(func(std::declval< T >()))>
 Applies a function to the result of the coroutine.
TFuture< void > Ignore ()
 Awaits the coroutine and ignores its result.
Public Member Functions inherited from NNet::TFutureBase< T >
 TFutureBase (TPromise< T > &promise)
 TFutureBase (TFutureBase &&other)
 TFutureBase (const TFutureBase &)=delete
TFutureBase & operator= (const TFutureBase &)=delete
TFutureBase & operator= (TFutureBase &&other)
bool await_ready () const
bool done () const
std::coroutine_handle raw ()
void await_suspend (std::coroutine_handle<> caller)

Additional Inherited Members

Public Types inherited from NNet::TFutureBase< T >
using promise_type = TPromise<T>
Protected Attributes inherited from NNet::TFutureBase< T >
std::coroutine_handle< TPromise< T > > Coro = nullptr

Detailed Description

template<typename T>
struct NNet::TFuture< T, TEagerFuturePolicy >

Owned coroutine handle that carries a result of type T.

RAII: destroys the coroutine frame in ~TFuture. Move-only. co_await future suspends the caller until the coroutine finishes, then returns T or rethrows a stored exception. future.done() polls completion without suspending.

Template Parameters
TThe type of the result.

Member Function Documentation

◆ Apply()

template<typename T>
template<typename Func>
auto NNet::TFuture< T, TEagerFuturePolicy >::Apply ( Func func) ->TFuture< decltype(func(std::declval< T >()))>
inline

Applies a function to the result of the coroutine.

The provided function is applied to the result, and the outcome is wrapped in a new future.

Template Parameters
FuncThe type of the function.
Parameters
funcThe function to apply.
Returns
A TFuture wrapping the result of the function call.

◆ Ignore()

template<typename T>
TFuture< void > NNet::TFuture< T, TEagerFuturePolicy >::Ignore ( )

Awaits the coroutine and ignores its result.

This is useful when the result is not needed.

Returns
TFuture<void> representing the completion.

The documentation for this struct was generated from the following file: