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

Future type for coroutines returning a value of type T. More...

#include <corochain.hpp>

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

Public Member Functions

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
 
TFutureBaseoperator= (const TFutureBase &)=delete
 
TFutureBaseoperator= (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 >

Future type for coroutines returning a value of type T.

Provides mechanisms to await and retrieve the result of a coroutine.

Template Parameters
TThe type of the result.

Member Function Documentation

◆ Apply()

template<typename T>
template<typename Func>
auto NNet::TFuture< T >::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 >::Ignore ( )
inline

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: