|
| | Future ()=default |
| |
| | Future (const Future &)=delete |
| |
| Future & | operator= (const Future &)=delete |
| |
| Future & | operator= (Future &&oldFuture) |
| |
| | Future (Future &&oldFuture) |
| | Thread and interrupt save move that re-registers stack pointer in between the future and the promise.
|
| |
| | ~Future () |
| |
| bool | is_connected () const |
| |
| bool | is_detatched () const |
| |
| bool | is_connected_to (const Promise< T > &promise) const |
| | Checks if the promise is connected to the future.
|
| |
| void | wait () |
| | Blocks the current thread until the value is ready or an error occured.
|
| |
| T & | get () |
| | returns the value of the future and waits if necessary
|
| |
| T * | get_if () |
| | returns the value of the future and waits if necessary. If the value does not exist, a nullptr is being returned
|
| |
| State | get_state () const |
| |
| State | state () const |
| |
| constexpr bool | is_ready () const |
| | returns true if the value is ready to read
|
| |
| constexpr | operator bool () const |
| | converts to a boolean. same as calling is_ready().
|
| |
| constexpr bool | is_waiting () const |
| | returns true if the result is not finished yet and one has to wait
|
| |
| constexpr bool | is_broken_promise () const |
| | return true if the promise was not kept
|
| |
| constexpr bool | await_ready () const noexcept |
| | co_await interoperability, returns true, if the future is no longer waiting.
|
| |
| std::optional< T > | await_resume () noexcept |
| | co_await interoperability and optionally returns a value if one has been set.
|
| |
template<class T>
class fiber::Future< T >
Future and Promise pairs are used to synchronise values between asynchronous tasks.
If you are on a multi core bare-metal embedded system you can set the FIBER_MULTI_CORE definiteion flag that will enable safeguards and lock mechanisms - smaller binary and faster execution. In single core mode (FIBER_MULTI_CORE=OFF), 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.
{
int crc = future_crc.
get();
}
T & get()
returns the value of the future and waits if necessary
Definition Future.hpp:215
constexpr bool is_ready() const
returns true if the value is ready to read
Definition Future.hpp:263
To create a future promise pair use:
FuturePromisePair< T > make_future_promise()
creates a linked future promise pair
Definition Future.hpp:751