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

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

#include <future.hpp>

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

Public Member Functions

 FutureOn (detail::ResultCorePtr< V, E > core) noexcept
 
Future< V, EOn (std::nullptr_t) &&noexcept
 Specify executor for continuation.
 
template<typename Func >
auto ThenInline (Func &&f) &&
 Attach the continuation func to *this.
 
template<typename Func >
auto Then (Func &&f) &&
 Attach the continuation func to *this.
 
template<typename Func >
void Detach (Func &&f) &&
 Attach the final continuation func to *this and Detach *this.
 
void Detach () &&noexcept
 Disable calling Stop in destructor.
 
template<typename Func >
void Detach (IExecutor &e, Func &&f) &&
 Attach the final continuation func to *this and Detach *this.
 
template<typename Func >
auto Then (IExecutor &e, 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::FutureOn< 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
simple.cpp.

Definition at line 232 of file future.hpp.

Constructor & Destructor Documentation

◆ FutureOn()

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

Definition at line 240 of file future.hpp.

References yaclib::MakeContract().

Member Function Documentation

◆ Detach() [1/3]

template<typename V , typename E >
void yaclib::FutureBase< V, E >::Detach ( ) &&
inlinenoexcept

Disable calling Stop in destructor.

Definition at line 141 of file future.hpp.

◆ Detach() [2/3]

template<typename V , typename E >
template<typename Func >
void yaclib::FutureOn< V, E >::Detach ( Func &&  f) &&
inline

Attach the final continuation func to *this and Detach *this.

Note
Func must return void type.
Parameters
fA continuation to be attached

Definition at line 285 of file future.hpp.

References yaclib::MakeContract().

◆ Detach() [3/3]

template<typename V , typename E >
template<typename Func >
void yaclib::FutureBase< V, E >::Detach ( IExecutor e,
Func &&  f 
) &&
inline

Attach the final continuation func to *this and Detach *this.

The func will be executed on the specified executor.

Note
The behavior is undefined if Valid is false before the call to this function.
Parameters
eExecutor which will Execute the continuation
fA continuation to be attached

Definition at line 168 of file future.hpp.

◆ On()

template<typename V , typename E >
Future< V, E > yaclib::FutureOn< V, E >::On ( std::nullptr_t  ) &&
inlinenoexcept

Specify executor for continuation.

Make FutureOnFuture with executor

Definition at line 247 of file future.hpp.

◆ Then() [1/2]

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

Attach the continuation func to *this.

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

Definition at line 273 of file future.hpp.

References yaclib::MakeContract().

Referenced by TEST().

◆ Then() [2/2]

template<typename V , typename E >
template<typename Func >
auto yaclib::FutureBase< V, E >::Then ( IExecutor e,
Func &&  f 
) &&
inline

Attach the continuation func to *this.

The func will be executed on the specified executor.

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

Definition at line 132 of file future.hpp.

◆ ThenInline()

template<typename V , typename E >
template<typename Func >
auto yaclib::FutureOn< 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 FutureOn object associated with the func result

Definition at line 260 of file future.hpp.

References yaclib::MakeContract().


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