-
Notifications
You must be signed in to change notification settings - Fork 15
Allow deletionof Tasks #7
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
Conversation
This operator does not need to be deleted. It prevents object from being deleted after destruction. There is no use-case for that.
The only thing aboud a STaticTask is how the memory is allocated. If it is allocated with operator new, there is no reason why it can't be deleted. And that should kill the task.
If I remember correctly, the thought here was that since After your suggestion for adding placement
Yes, you are probably right. Out of curiosity are you trying to use placement
Out of curiosity what does this design look like for you? For most of my projects everything is statically allocated for the lifetime of the program, so I haven't paid as much attention to these scenarios. |
|
Before merging this I think it would make sense to move the FreeRTOS "delete" functions into the base classes. Let me know if that lines up with your logic. |
|
Thanks for looking into this. I am away this week, so only have accees to a phone. Apologies for slow replies! I used placement-new an indeed tried to delete the task when it is no longer needed. This may change from spawning tasks to creating other helpers, such as timers. The context is a device with a stm32h7 mcu. The device has connectors to which accesoires can be connected. We need 'drivers' . I would usually statically allocate everything, but in this case the hardware us nit static. And having all different drivers running at all time doesn't sound good. |
yes, that is what I was thinking. I'm not sure, but some classes already do it like that. At leat Task didn't. |
Done. I'll leave this up for you to take a look at the changes when you return. Thanks for the help! |
|
Those changes look good. I just didn't check the destructors of other objects before. Only Timer, which does have the destructor in the base class. |
operator delete(void*) was deleted. This prevented deletion of any task. I don't see a reason for that, and no need to delete the operator.
Additionally, I think a StaticTask should be able to be removed.
For context: I have a device where devices can be added to an i2c bus, and later be removed. I want to handle that on a dynamically allocated task.