Not in an IRQ but just when an event happens. Sometimes I want to print a value every X seconds. If an IRQ is hidden under so many layers of abstraction its easy to put code in a place where it shouldn't be.
You say that someone is prone to put IRQ forbidden stuff on onTick or similar event which is called from an IRQ.. Nice point, and I loved the idea.. I'll think about that.. I may move all timer related stuff to task level. It is easy for timers, however need to think on other peripheral abstractions, and notations.. For instance you would want fast response, in IRQ level on GpioInterrupt class, or ExternalInterrupt which bonds to a pin.. Thinking on this, here comes an idea:
timer.onTick = makeAsync(handleTimerTick);
makeIrqSafe or something like that.. now handleTimerTick is handled by task, not irq.. what about this?
Testing on interns are good measure.. But why do you think the second WorkList example is complicated? It just passes flow to a task.. Would it be easier to understand if we drop "workList" idiom, and just do it like that:
void doPrintf(void* sender, void* param)
{
printf("....", (Int)param);
}
void handleTimerTick(void* sender, void* param)
{
callAsync(doPrintf, 1);
}
I know, as you mentioned and I described above, being able to IRQ safe is the best, however just thinking about calling a function from IRQ.. callAsync hides WorkList stuff, it uses defaultWorkList. It is overloaded to make usage easier, this one uses Int as param..
What do you think?