|
fiber
|
Promise and Future pairs are used to synchronise values between asynchronous tasks. More...
#include <Future.hpp>
Public Member Functions | |
| Promise ()=default | |
| Promise (const Promise &)=delete | |
| Promise & | operator= (Promise &&oldPromise) |
| Thread and interrupt save move save move that re-registers stack pointers in between the future and the promise. | |
| Promise (Promise &&oldPromise) | |
| bool | is_connected_to (const Future< T > &future) const |
| Checks if the passed future is the one connected to this promise. | |
| ~Promise () noexcept | |
| Signals a broken promise to the future if no value has been assigned to the promise before destruction. | |
| void | set_value (const T &value) |
| Sets a value to the future that this promise is based on. | |
| Promise & | operator= (const T &value) |
equivalent to set_value() | |
| void | set_value (T &&value) |
| Sets a value to the future that this promise is based on. | |
| Promise & | operator= (T &&value) |
equivalent to set_value() | |
Friends | |
| class | Future< T > |
| FuturePromisePair< T > | make_future_promise () |
| creates a linked future promise pair | |
Promise and Future pairs are used to synchronise values between asynchronous tasks.
If you are on a single core bare-metal embedded system (aka. all context switching is interrupt driven) you can set the FIBER_MULTI_CORE definiteion flag for optimizations - smaller binary and faster execution. It will then remove all the locks and logic that is needed for multi-core thread safety.
Example: one wants to copy data asynchronously (for example with a DMA controller) while doing some computations in the mean time.
|
default |
|
delete |
|
inline |
|
inlinenoexcept |
Signals a broken promise to the future if no value has been assigned to the promise before destruction.
|
inline |
Checks if the passed future is the one connected to this promise.
true if the passed future is the same that this promise is connected to.
|
inline |
equivalent to set_value()
|
inline |
Thread and interrupt save move save move that re-registers stack pointers in between the future and the promise.
|
inline |
equivalent to set_value()
|
inline |
Sets a value to the future that this promise is based on.
| value | The value that should be set to the Future and "keep the promise". |
| an | std::exception on double writes |
|
inline |
Sets a value to the future that this promise is based on.
| value | The value that should be set to the Future and "keep the promise" |
| an | fiber::Exception on double writes |
|
friend |
|
friend |
creates a linked future promise pair
Example:
| T | The type that is being promised by the promise and awaited by the future |
FuturePromisePair Future promise pair