FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Abstract class to allow aggregation of several futures. More...
#include <fastarduino/future.h>
Protected Member Functions | |
AbstractFuturesGroup (FutureNotification notifications=FutureNotification::NONE) | |
Construct a new AbstractFuturesGroup. More... | |
void | init (utils::range< F * > futures, uint16_t actual_size=0) |
Called from constructors of subclasses, this method allows this group to listen for the status of all its futures. More... | |
void | on_status_change_pre_step (const F &future, FutureStatus status) |
This must be called by subclasses on_status_change() method, after checking that future is one of the futures handled by this instance, and before performing any further processing. More... | |
Static Protected Attributes | |
static constexpr const uint16_t | NO_LIMIT = 0xFFFFU |
Specific size value indicating this group has an unlimited (and unknown at construction time) number of futures to handle. More... | |
Abstract class to allow aggregation of several futures.
This allows to await()
for all futures, or query the overall status()
of the group.
The following snippet shows how this must be used to create an actual group of futures:
In that snippet, MyGroup
embeds 3 different futures, each of a different type; the 3 futures are constructed at MyGroup
construction time, and their pointers passed to the parent FuturesGroup
. Three getter methods allow the application to access individual futures.
Note the calls to interrupt::register_handler()
and interrupt::unregister_handler()
in the constructor and the destructor.
Also note the on_status_change()
method, that will be called whenever any individual future has its status modified.
Finally, for the notification mechanism to work MyGroup
must be registered as a listener, which is done with REGISTER_FUTURE_STATUS_LISTENERS()
.
F | the type of Future to aggregate int this group; this shall be either AbstractFuture or AbstractFakeFuture . |
|
inlineexplicitprotected |
Construct a new AbstractFuturesGroup.
The created Group is in FutureStatus::NOT_READY
status. The Future holds buffers to store both the input storage value and the output value. The subclass constructor must call init()
with the list of futures in this group.
notifications | determines if and which notifications should be dispatched by this Future; default is none. |
|
inlineprotected |
Called from constructors of subclasses, this method allows this group to listen for the status of all its futures.
futures | list of pointers to futures in this group |
actual_size | real number of futures; if 0 (default), this will match the size of futures ; it may be bigger than the actual number of futures if e.g. a future is reused several times in this group; if NO_LIMIT , then the subclass does not know in advance how many times its futures shall be used, in this case, the subclass must itself indicate when this group of future is FutureStatus::READY . |
|
inlineprotected |
This must be called by subclasses on_status_change()
method, after checking that future
is one of the futures handled by this instance, and before performing any further processing.
future | a reference to the future which status has changed |
status | the new status of future |
|
staticconstexprprotected |