freertos-addons
freertos-addons copied to clipboard
Refactor Queue as a Template
I think it would be a safer and more C++ style usage of the Queue's to take a template argument T and a runtime queue-size as the only constructor argument.
Something like:
struct MyEvent {
uint32_t id;
uint16_t element1;
uint16_t element2;
};
...
cpp_freertos::Queue<MyEvent> event_queue(5); // Event queue that holds 5 MyEvents
The rationale here is the specialization makes the type that is inside the queue well known, and functions that return objects can now take T& instead of pointers, preventing null pointer errors at compile time.