MEL
Microthread & Execution library
mel::core::Future_Common< T > Class Template Reference

Common code for Futures that doesn't need to be templated. More...

#include <Future.h>

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

Public Member Functions

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...
 
 Future_Common (const Future_Common &f) noexcept
 
 Future_Common (Future_Common &&f) noexcept
 
Future_Commonoperator= (const Future_Common &f) noexcept
 
Future_Commonoperator= (Future_Common &&f) noexcept
 

Detailed Description

template<typename T>
class mel::core::Future_Common< T >

Common code for Futures that doesn't need to be templated.

Template Parameters
T

Member Function Documentation

◆ assign()

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

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 ( )
inline

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
inline

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
inline

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
inline

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: