Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: tasks/periodic_task.cpp
- Revision:
- 3:bd96023168df
- Parent:
- 1:4eccf61f4ef7
--- a/tasks/periodic_task.cpp Wed Jul 13 09:01:16 2016 +0000 +++ b/tasks/periodic_task.cpp Tue Dec 13 14:48:48 2016 +0100 @@ -2,17 +2,19 @@ namespace SimpleTaskScheduler { - void PeriodicTask::run(void) { - if (state == SHOULD_RUN) { + void PeriodicTask::run(void) { + if (nextState == SHOULD_RUN) { state = RUNNING; - this->callback.call(); + this->call(); state = WAITING; + nextState = WAITING; } } void PeriodicTask::tick(void) { - // Following can mess with your day if your task is long and periodic periodic - //period is small. - state = SHOULD_RUN; + // Following can mess with your day if task is long and period is small + if (nextState == WAITING) { + nextState = SHOULD_RUN; + } } };