Represents a value that maybe is not present at the current moment.
More...
#include <Future.h>
|
|
typedef _private::FutureData< T >::ValueType | ValueType |
| |
|
|
| Future (const Future &f) noexcept |
| |
|
| Future (Future &&f) noexcept |
| |
|
| Future (const T &val) |
| |
|
| Future (T &&val) |
| |
|
Future & | operator= (const Future &f) noexcept |
| |
|
Future & | operator= (Future &&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...
|
| |
template<typename T>
class mel::core::Future< T >
Represents a value that maybe is not present at the current moment.
This value will be generated by someone and will be available at "some moment" The value is retrieved using various ways:
callback notification with Future_Common::subscribeCallback should check getValid, in which case there is an error ( see error )
◆ assign()
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]
◆ getValue() [2/2]
◆ subscribeCallback()
template<typename T >
template<class F >
Subscribe callback to be executed when future is ready (valid or error)
- Parameters
-
- 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()
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:
- /github/workspace/mel/include/core/Future.h