arkhipenko / TaskScheduler

Cooperative multitasking for Arduino, ESPx, STM32, nRF and other microcontrollers
http://playground.arduino.cc/Code/TaskScheduler
BSD 3-Clause "New" or "Revised" License
1.21k stars 221 forks source link

Feature request: Add optional name field to tasks #131

Closed joemcool closed 2 years ago

joemcool commented 2 years ago

I'd like to add the option to specify a name for a Task. I'm imagining this could be set when the constructor is run, and reset later with an accessor method. I'm planning to use this feature to generate a list of currently active tasks with some information about each (interval, active/disabled status, overrun status, and eventually per Task load).

Is there any objection to putting this feature in? I didn't see any old issues discussing it, and was a little surprised it wasn't there already. Maybe there's a reason it was not put in?

arkhipenko commented 2 years ago

The reason why it was never implemented (and will never be) is that I strive to minimize the memory footprint of the library. Task names are non-essential information. You are free and welcome to maintain a map of task IDs to a an array of names if you really need this functionality. It has never been before requested and I personally never needed such. I know that FreeRTOS assigns a name to a task, and this is in my opinion just a waste of memory.

You can identify Tasks by IDs if you enable _TASK_WDT_IDS

joemcool commented 2 years ago

Got it. Thanks for the context!

arkhipenko commented 2 years ago

You are welcome, and thank you for doing the research on the previous issues before requesting - this is rare and appreciated.