-
Notifications
You must be signed in to change notification settings - Fork 251
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
Way to shutoff the catchup #103
Comments
Not the first time this is requested - I am thinking about it... |
ok. just pushed version 3.2.0 update to the testing branch - please test if you have time. If you compile with this
Here is the output with explanations:
three tasks are scheduled with a 10 ms space between them, each runs 10 times with 100 ms interval. there is a 333 ms delay before first invokation
all tasks start as soon as possible
t1 tries to catch upi immediately
t2 tries to maintain an original schedule (s/b 1443), but is pushed a little by t1
likewise, t1 is trying to run at 1433, but is pushed by t2
t3, with priority for the interval, not schedule, runs at 1506 (1406 + 100 ms) as scheduled
finally, all tasks are caught up with their respective schedules (t1 at x33, t2 at x43 and t3 at x06)
t1 finishes early because of the "catch-up"
rest of the tasks finish their 10 iterations later because they skipped "catch up". |
Looks good. I just tested it and it worked. Thanks. |
I would suggest to add a new feature. We would need a dontCatchup bool and a function setDontCatchup(). Then change line 1014 of the TaskScheduler.h to say:
if (dontCatchup) iCurrent->iPreviousMilis = m + iCurrent->iDelay;
else iCurrent->iPreviousMillis += iCurrent->iDelay;
The reason is I have been using the task scheduler on an ESP and I was having some trouble with delays in a task. Yes, I know, tasks should not have delays, but sometimes they do. I can't always get around it. So, when a task delays, then, as you know, the scheduler tries to catchup by issuing all tasks that should have already run. On my program though, all tasks are periodical, so I would prefer to loose the extra tasks. I have tried using a hack where I scan the list for overrun tasks, set delay(0) and then clear the iOverrun variable, but it is a bit messy. The above feature I would think would be a clean way to support this kind of task.
The text was updated successfully, but these errors were encountered: