In the mbed-events library, the structure of an event is correctly hidden from the public api. Unfortunately, this makes it difficult to calculate the space needed for a finite-set of events.
In this pr, EVENTS_EVENT_SIZE is defined as the space needed for a single Callback<void()> event.
This allows queues to be created with the exact size required for Callback<void()> or any callback with a single word of associated context:
EventQueue queue(12 * EVENTS_EVENT_SIZE);
For events with different sized contexts, the exact size can still be calculated, although it is quite a bit uglier. This should be less common than Callback<void()>, and was shown in previous versions to be difficult to reason about when compared to raw buffer sizes:
In the mbed-events library, the structure of an event is correctly hidden from the public api. Unfortunately, this makes it difficult to calculate the space needed for a finite-set of events.
In this pr, EVENTS_EVENT_SIZE is defined as the space needed for a single Callback<void()> event.
This allows queues to be created with the exact size required for Callback<void()> or any callback with a single word of associated context:
For events with different sized contexts, the exact size can still be calculated, although it is quite a bit uglier. This should be less common than Callback<void()>, and was shown in previous versions to be difficult to reason about when compared to raw buffer sizes: