I have a task that when it reaches a loop it needs to process that loop few hundreds or sometimes even thousands of times as fast as possible (allowing for some basic notification processing).
To be more specific, I have printing nozzles that need to fire very fast and in a synchronised manner because the drum is rotating at a constant (high) speed and cannot be slowed down. That loop takes care of that and is increased in priority while in the loop (i.e. increased before the loop start and decreased when the loop completes).
While in the loop the task can receive many different types notifications from other tasks. but only one or two emergency notifications are allowed to stop the loop.
What is the best way to implement this with:
a) minimal time wasting in the loop AND
b) without having to process and discard (effectively lose) other prior notifications that are in the task queue
Do I have to have a taskNotifyTake() inside the loop every cycle?
how can I check and extract only the “emergency” notification that might be 5 or 10 positions down the queue qithout loosing the previous ones which will need to be processed later on when outside the loop?