cortex 0.0.1
Loading...
Searching...
No Matches
cortex::tiny_fiber::Future< T > Class Template Reference

Handle to a spawned fiber that returns a value. More...

#include <future.hpp>

Public Member Functions

 Future (const Future &)=delete
 
Futureoperator= (const Future &)=delete
 
 Future (Future &&other) noexcept
 
Futureoperator= (Future &&other) noexcept
 
 ~Future ()
 
void Wait ()
 Block current fiber until this fiber completes.
 
T Get ()
 Block until fiber completes and return the result.
 
bool IsReady () const noexcept
 Check if the fiber has completed.
 

Friends

template<typename U >
Future< USpawn (std::function< U()> func)
 
template<typename U >
Future< USpawn (std::function< U()> func, std::size_t stack_size)
 
template<typename F >
auto Spawn (F &&func) -> Future< std::invoke_result_t< F > >
 Spawn a new fiber.
 
template<typename F >
auto Spawn (F &&func, std::size_t stack_size) -> Future< std::invoke_result_t< F > >
 Spawn a new fiber with custom stack size.
 

Detailed Description

template<typename T>
class cortex::tiny_fiber::Future< T >

Handle to a spawned fiber that returns a value.

Template Parameters
TThe return type of the fiber.

Constructor & Destructor Documentation

◆ Future() [1/2]

template<typename T >
cortex::tiny_fiber::Future< T >::Future ( const Future< T > &  )
delete

◆ Future() [2/2]

template<typename T >
cortex::tiny_fiber::Future< T >::Future ( Future< T > &&  other)
inlinenoexcept

◆ ~Future()

template<typename T >
cortex::tiny_fiber::Future< T >::~Future ( )
inline

Member Function Documentation

◆ Get()

template<typename T >
T cortex::tiny_fiber::Future< T >::Get ( )
inline

Block until fiber completes and return the result.

Returns
The result of the fiber.
Exceptions
Anyexception thrown by the fiber.

◆ IsReady()

template<typename T >
bool cortex::tiny_fiber::Future< T >::IsReady ( ) const
inlinenoexcept

Check if the fiber has completed.

◆ operator=() [1/2]

template<typename T >
Future & cortex::tiny_fiber::Future< T >::operator= ( const Future< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
Future & cortex::tiny_fiber::Future< T >::operator= ( Future< T > &&  other)
inlinenoexcept

◆ Wait()

template<typename T >
void cortex::tiny_fiber::Future< T >::Wait ( )
inline

Block current fiber until this fiber completes.

Friends And Related Symbol Documentation

◆ Spawn [1/4]

template<typename T >
template<typename F >
auto Spawn ( F &&  func) -> Future<std::invoke_result_t<F>>
friend

Spawn a new fiber.

Parameters
funcThe function to execute in the fiber.
Returns
A Future to wait for the result.

◆ Spawn [2/4]

template<typename T >
template<typename F >
auto Spawn ( F &&  func,
std::size_t  stack_size 
) -> Future<std::invoke_result_t<F>>
friend

Spawn a new fiber with custom stack size.

Parameters
funcThe function to execute in the fiber.
stack_sizeThe stack size for the fiber.
Returns
A Future to wait for the result.

◆ Spawn [3/4]

template<typename T >
template<typename U >
Future< U > Spawn ( std::function< U()>  func)
friend

◆ Spawn [4/4]

template<typename T >
template<typename U >
Future< U > Spawn ( std::function< U()>  func,
std::size_t  stack_size 
)
friend

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