MEL
Microthread & Execution library
mel::execution::ExFuture< ExecutorAgent, ResultType > Class Template Reference

Extension of mel::core::Future to apply to executors. More...

#include <ExFuture.h>

Inheritance diagram for mel::execution::ExFuture< ExecutorAgent, ResultType >:
mel::core::Future< T > mel::core::Future_Common< T >

Public Types

typedef _private::FutureData< T >::ValueType ValueType
 

Public Member Functions

 ExFuture (const ExFuture &ob) noexcept
 
 ExFuture (ExFuture &&ob) noexcept
 
 ExFuture (Executor< ExecutorAgent > aEx) noexcept
 
 ExFuture (Executor< ExecutorAgent > aEx, const ResultType &val)
 
 ExFuture (Executor< ExecutorAgent > aEx, ResultType &&val)
 
ExFutureoperator= (const ExFuture &f) noexcept
 
ExFutureoperator= (ExFuture &&f) noexcept
 
template<class F >
void setValue (F &&value)
 
template<class F >
void setError (F &&ei)
 
const _private::FutureData< T >::ValueType & getValue () const
 Get the Value object. More...
 
_private::FutureData< T >::ValueType & getValue ()
 Get the Value object. More...
 
void assign (const typename _private::FutureData< T >::ValueType &val)
 
void assign (typename _private::FutureData< T >::ValueType &&val)
 
void assign (Future_Common< T > val)
 Makes this Future to point to the same value as the given Future. More...
 
template<class F >
int subscribeCallback (F &&f) const
 Subscribe callback to be executed when future is ready (valid or error) More...
 
int unsubscribeCallback (int id) const
 Unsubscribe given callback. More...
 

Public Attributes

Executor< ExecutorAgent > agent
 execution agent associated with this instance
 

Detailed Description

template<typename ExecutorAgent, typename ResultType>
class mel::execution::ExFuture< ExecutorAgent, ResultType >

Extension of mel::core::Future to apply to executors.

Any executor function will return an ExFuture, allowing this way to chain functions

Member Function Documentation

◆ assign()

template<typename T >
void mel::core::Future_Common< T >::assign ( Future_Common< T >  val)
inlineinherited

Makes this Future to point to the same value as the given Future.

This ways, both futures will share the same value/error. If input Future is already set at that moment, callbacks are triggered as usual. It's important to note that all futures sharing same data will change

◆ getValue() [1/2]

template<typename T >
_private::FutureData<T>::ValueType& mel::core::Future_Common< T >::getValue ( )
inlineinherited

Get the Value object.

Returns
const mel::core::FutureValue

◆ getValue() [2/2]

template<typename T >
const _private::FutureData<T>::ValueType& mel::core::Future_Common< T >::getValue ( ) const
inlineinherited

Get the Value object.

Returns
const mel::core::FutureValue

◆ subscribeCallback()

template<typename T >
template<class F >
int mel::core::Future_Common< T >::subscribeCallback ( F &&  f) const
inlineinherited

Subscribe callback to be executed when future is ready (valid or error)

Parameters
[in]FCallable with signature void( \ref mel::core::FutureValue& )
Warning
Usually callback is executed in the context of the thread doing setValue, but if Future is already ready callback will be executed in the context of the thread doing subscription. In general, for this and more reasons, callbacks responses should be done buy launchin a task, so decoupliing totally the diferent tasks
Returns
callback id

◆ unsubscribeCallback()

template<typename T >
int mel::core::Future_Common< T >::unsubscribeCallback ( int  id) const
inlineinherited

Unsubscribe given callback.

because use of lambda, unsubscription can only be done by id (returned by subscribeCallback)


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