|
FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Utility API to handle the concept of futures. More...
#include <string.h>#include "flash.h"#include "interrupts.h"#include "iterator.h"#include "errors.h"#include "time.h"

Go to the source code of this file.
Classes | |
| class | future::AbstractFuture |
Base class for all Futures. More... | |
| class | future::Future< OUT_, IN_ > |
| Represent a value to be obtained, in some asynchronous way, in the future. More... | |
| class | future::AbstractFakeFuture |
Base class for all FakeFutures. More... | |
| class | future::FakeFuture< OUT_, IN_ > |
| Actual FakeFuture, it has the exact same API as Future and can be used in lieu of Future. More... | |
| class | future::AbstractFuturesGroup< F > |
| Abstract class to allow aggregation of several futures. More... | |
Namespaces | |
| namespace | future |
| Contains the API around Future implementation. | |
Macros | |
| #define | REGISTER_FUTURE_STATUS_LISTENERS(ABSTRACT_TYPE, HANDLER1, ...) |
Register the necessary callbacks that will be notified when a future::Future (or a future::FakeFuture) has its status changed. More... | |
| #define | REGISTER_FUTURE_STATUS_NO_LISTENERS() |
| Register no callback at all to Future status changes notification. More... | |
| #define | REGISTER_FUTURE_OUTPUT_LISTENERS(ABSTRACT_TYPE, HANDLER1, ...) |
Register the necessary callbacks that will be notified when a future::Future (or a future::FakeFuture) has its output content filled in, even partly. More... | |
| #define | REGISTER_FUTURE_OUTPUT_NO_LISTENERS() |
| Register no callback at all to Future output buffer changes notification. More... | |
| #define | REGISTER_FUTURE_NO_LISTENERS() |
| Register no callback at all to any Future notification. More... | |
| #define | DECL_FUTURE_LISTENERS_FRIEND template<typename> friend struct future::dispatch_handler_impl; |
This macro shall be used in a class containing a private callback method void on_status_change(const ABSTRACT_TYPE&, FutureStatus), registered by REGISTER_FUTURE_STATUS_LISTENERS, or void on_output_change(const ABSTRACT_TYPE&), registered by REGISTER_FUTURE_OUTPUT_LISTENERS. More... | |
Enumerations | |
| enum class | future::FutureStatus : uint8_t { future::NOT_READY = 0 , future::READY , future::ERROR , future::INVALID } |
| Status of a Future. More... | |
| enum class | future::FutureNotification : uint8_t { future::NONE = 0 , future::STATUS = 1 , future::OUTPUT = 2 , future::BOTH = 3 } |
| Notification(s) dispatched by a Future. More... | |
Utility API to handle the concept of futures.
For general discussion about this concept, please check https://en.wikipedia.org/wiki/Futures_and_promises
Definition in file future.h.
| #define REGISTER_FUTURE_STATUS_LISTENERS | ( | ABSTRACT_TYPE, | |
| HANDLER1, | |||
| ... | |||
| ) |
Register the necessary callbacks that will be notified when a future::Future (or a future::FakeFuture) has its status changed.
FutureNotification::STATUS or FutureNotification::BOTH notifications parameter will produce such notifications.Each handler registered here will be notified of status changes for ALL futures producing such notifications.
| ABSTRACT_TYPE | one of AbstractFuture or AbstractFakeFuture; any other type will fail compilation. |
| HANDLER1 | a class which registered instance will be notified, through its void on_status_change(const ABSTRACT_TYPE&, FutureStatus) method when a notifying future has its status changed. |
| ... | other classes similar to HANDLER1. |
| #define REGISTER_FUTURE_STATUS_NO_LISTENERS | ( | ) |
Register no callback at all to Future status changes notification.
You normally do not need this macro, except if you:
future::AbstractFuturesGroup (directlty or indirectlty, some I2C devices use it)| #define REGISTER_FUTURE_OUTPUT_LISTENERS | ( | ABSTRACT_TYPE, | |
| HANDLER1, | |||
| ... | |||
| ) |
Register the necessary callbacks that will be notified when a future::Future (or a future::FakeFuture) has its output content filled in, even partly.
FutureNotification::OUTPUT or FutureNotification::BOTH notifications parameter will produce such notifications.Each handler registered here will be notified of output changes for ALL futures producing such notifications.
| ABSTRACT_TYPE | one of AbstractFuture or AbstractFakeFuture; any other type will fail compilation. |
| HANDLER1 | a class which registered instance will be notified, through its void on_output_change(const ABSTRACT_TYPE&) method when a notifying future has its output content filled in. |
| ... | other classes similar to HANDLER1. |
| #define REGISTER_FUTURE_OUTPUT_NO_LISTENERS | ( | ) |
Register no callback at all to Future output buffer changes notification.
You normally do not need this macro, except if you:
| #define REGISTER_FUTURE_NO_LISTENERS | ( | ) |
Register no callback at all to any Future notification.
You normally do not need this macro, except if you:
| #define DECL_FUTURE_LISTENERS_FRIEND template<typename> friend struct future::dispatch_handler_impl; |
This macro shall be used in a class containing a private callback method void on_status_change(const ABSTRACT_TYPE&, FutureStatus), registered by REGISTER_FUTURE_STATUS_LISTENERS, or void on_output_change(const ABSTRACT_TYPE&), registered by REGISTER_FUTURE_OUTPUT_LISTENERS.
It declares the class where it is used as a friend of all necessary functions so that the private callback method can be called properly.