✨ FreeRtos queue wrapper class#691
Conversation
|
Motivation? What usecase does |
|
Freertos queue receive will block current task until data got send into the queue. |
|
It is mainly for the data sharing between 2(or multiple? Im not sure abot this) tasks. |
A thread safe queue class based on Also, it looks like the changes from your other PR #690 accidentally got added in this PR as well, you should probably fix that. |
|
Also this class won't work properly for types that have non trivial copy constructors (and I don't think there's any easy way of fixing that because of how the C API works). |
|
I think that is not an issue because it's for passing data. It's not for passing complex objects. Also, the thread safe queue will work, but that shouldn't be in kernel. |
| class Queue { | ||
| queue_t queue; | ||
|
|
||
| public: |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm not going to use static assert, it does not work well with intellisense. I'll use concept.
| Queue& operator=(Queue&&) = delete; | ||
|
|
||
| void delete_queue() { | ||
| pros::c::queue_delete(queue); |
There was a problem hiding this comment.
| pros::c::queue_delete(queue); | |
| if (!deleted) { | |
| pros::c::queue_delete(queue); | |
| deleted = true; | |
| } |
| } | ||
|
|
||
| ~Queue() { | ||
| pros::c::queue_delete(queue); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| template <class T> | ||
| class Queue { | ||
| queue_t queue; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Strongly disagree, if we have a type template in C++ then it should work with C++ types. We can add a type constraint for trivially_constructible but at that point, wouldn't you rather just have something that actually works with everything? I don't see the point when it's strictly worse than another option.
Then why is this? This is just a worse version of that. |
|
Bcuz freertos queue is already in kernal(apix.h), I just wrap it with a class, it's easier to use. |
|
I just don't really think we should be encouraging using something that's not really worth using by making it easier? Who is this for? There's a reason its in apix. |
Summary:
A wrapper class for freertos queue
Motivation:
Idk whether this should be in kernel, but this is very useful. For example, odometry and controller system.
Test Plan: