Task::delay is not public #2
Replies: 7 comments
-
I think the original idea here was to try and enforce the idea that any call to This helps prevent someone from calling
Another way to look at this is that
Here By this same logic |
Beta Was this translation helpful? Give feedback.
-
I understand. Indeed, delaying another task is confusing. What about a different approach: create a new class this_task, like so:
That way, the api makes it clearer thay you are delaying the current task, and there is no relation with a specific task. (admitted: this is inspired by https://github.com/IntergatedCircuits/freertos-mcpp/blob/master/include/freertos/thread.h#L443) |
Beta Was this translation helpful? Give feedback.
-
That is similar to what I do for other functions that are part of the This is a new library, so I'm not sure how people will use it yet. Are you wanting to use this functionality in many classes or just this one? Would it makes sense to declare your class a friend of your task class? |
Beta Was this translation helpful? Give feedback.
-
I am using the delay in a device driver that is to be used by multiple applications. So making that class a friend won't work, as the class is in a separate library. Moving delay to FreeRTOS::Kernel would work. I am not sure on how nice that solution is. But I also just starting using your library, so I am still looking for the best way to use it. |
Beta Was this translation helpful? Give feedback.
-
My initial thought/question would be why does your device driver need to delay the task? If someone else were to use the class would it unexpectedly be delaying the thread? A high-level guideline I would give for the library would be only delay the task from the task class (which is why it's protected). Construct the driver interface in way that doesn't "hide" thread delays from the application. If that doesn't work, I'd suggest making your driver it's own |
Beta Was this translation helpful? Give feedback.
-
I'm writing a library for my own use, not a public library. For me, the design of drivers or other library classes delaying the task work. I just make sure to document it. My MCU doesn't have enough memory to have many tasks. I can always add my own 'ThisTask' class ofcourse, if that doesn't fit in your design. |
Beta Was this translation helpful? Give feedback.
-
I would say do that for now. If it's just a static method I would throw it in a namespace. Something like:
The design is intended to stop you from doing exactly what you're trying to do, so I don't want to change it yet. If others also find this too restrictive then I'll consider changing it in the future. |
Beta Was this translation helpful? Give feedback.
-
I have a class that inherits from Task. This works very well. Thank you for these nice wrappers! Except that this class calls methods in other classes, which need to delay the current task. Those classes don't have access to Task::delay, because it is protected. For me, it would help if it was public.
Is there any objection against that?
Beta Was this translation helpful? Give feedback.
All reactions