Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Queue as a Template #56

Open
AsimmHirani opened this issue Jan 22, 2024 · 0 comments
Open

Refactor Queue as a Template #56

AsimmHirani opened this issue Jan 22, 2024 · 0 comments

Comments

@AsimmHirani
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant