YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
yaclib::Future< V, E > Class Template Referencefinal

Provides a mechanism to access the result of async operations. More...

#include <future.hpp>

Inheritance diagram for yaclib::Future< V, E >:
[legend]
Collaboration diagram for yaclib::Future< V, E >:
[legend]

Public Member Functions

 Future (detail::ResultCorePtr< V, E > core) noexcept
 
template<typename Func >
auto ThenInline (Func &&f) &&
 Attach the continuation func to *this.
 
- Public Member Functions inherited from yaclib::FutureBase< V, E >
 FutureBase (const FutureBase &)=delete
 
FutureBaseoperator= (const FutureBase &)=delete
 
 FutureBase (FutureBase &&other) noexcept=default
 
FutureBaseoperator= (FutureBase &&other) noexcept=default
 
 FutureBase () noexcept=default
 The default constructor creates not a Valid Future.
 
 ~FutureBase () noexcept
 If Future is Valid then call Stop.
 
bool Valid () const &noexcept
 Check if this Future has Promise.
 
bool Ready () const &noexcept
 Check that Result that corresponds to this Future is computed.
 
void Get () &=delete
 
void Get () const &&=delete
 
void Touch () &=delete
 
void Touch () const &&=delete
 
const Result< V, E > * Get () const &noexcept
 Return copy of Result from Future.
 
Result< V, EGet () &&noexcept
 
const Result< V, E > & Touch () const &noexcept
 
Result< V, ETouch () &&noexcept
 
template<typename Func >
auto Then (IExecutor &e, Func &&f) &&
 Attach the continuation func to *this.
 
void Detach () &&noexcept
 Disable calling Stop in destructor.
 
template<typename Func >
void DetachInline (Func &&f) &&
 Attach the final continuation func to *this and Detach *this.
 
template<typename Func >
void Detach (IExecutor &e, Func &&f) &&
 Attach the final continuation func to *this and Detach *this.
 
detail::ResultCorePtr< V, E > & GetCore () noexcept
 Method that get internal Core state.
 

Additional Inherited Members

- Protected Member Functions inherited from yaclib::FutureBase< V, E >
 FutureBase (detail::ResultCorePtr< V, E > core) noexcept
 
- Protected Attributes inherited from yaclib::FutureBase< V, E >
detail::ResultCorePtr< V, E_core
 

Detailed Description

template<typename V, typename E>
class yaclib::Future< V, E >

Provides a mechanism to access the result of async operations.

Future and Promise are like a Single Producer/Single Consumer one-shot one-element channel. Use the Promise to fulfill the Future.

Examples
when_all.cpp, and when_any.cpp.

Definition at line 199 of file future.hpp.

Constructor & Destructor Documentation

◆ Future()

template<typename V , typename E >
yaclib::Future< V, E >::Future ( detail::ResultCorePtr< V, E core)
inlinenoexcept

Definition at line 205 of file future.hpp.

References yaclib::MakeContract().

Member Function Documentation

◆ ThenInline()

template<typename V , typename E >
template<typename Func >
auto yaclib::Future< V, E >::ThenInline ( Func &&  f) &&
inline

Attach the continuation func to *this.

The func will be executed on Inline executor.

Note
The behavior is undefined if Valid is false before the call to this function.
Parameters
fA continuation to be attached
Returns
New Future object associated with the func result

Definition at line 217 of file future.hpp.

References yaclib::MakeContract().


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