boost-ext / sml

C++14 State Machine library
https://boost-ext.github.io/sml
Boost Software License 1.0
1.16k stars 179 forks source link

allow the usage of "static queues" (based on std::array) for process_queue and defer_queue #615

Closed devzeb closed 8 months ago

devzeb commented 8 months ago

Problem:

All examples for sml::process_queue and sml::defer_queue are based on std::queue. While this approach is fine for desktop c++, some use cases exist where dynamic allocations are not allowed / desired.

Some examples are:

As boost::sml is a library that targets embedded systems, it should allow the use of pre-allocated queues.

Solution:

I enabled the use of pre-allocated queues by making queue_event default constructible. This allows storing instances of queue_event in a container that pre-allocates all elements upon construction (e.g. std::array).

I added additional tests in actions_process.cpp, actions_defer.cpp and actions_process_n_defer.cpp that use std::array based queues and deques.

kris-jusiak commented 8 months ago

Nice one, thanks @devzeb