-
Notifications
You must be signed in to change notification settings - Fork 77
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
✨ FreeRtos queue wrapper class #691
base: develop-pros-4
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to use static assert, it does not work well with intellisense. I'll use concept.
include/pros/rtos.hpp
Outdated
Queue& operator=(Queue&&) = delete; | ||
|
||
void delete_queue() { | ||
pros::c::queue_delete(queue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -820,6 +820,63 @@ struct Clock { | |||
static time_point now(); | |||
}; | |||
|
|||
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: