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.
tasks/periodic_task.cpp@1:4eccf61f4ef7, 2016-07-11 (annotated)
- Committer:
- dwini
- Date:
- Mon Jul 11 15:03:21 2016 +0000
- Revision:
- 1:4eccf61f4ef7
- Parent:
- periodic_task.cpp@0:ba0870ec8714
- Child:
- 3:bd96023168df
Move tasks to separate dir
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dwini | 0:ba0870ec8714 | 1 | #include "periodic_task.h" |
| dwini | 0:ba0870ec8714 | 2 | |
| dwini | 0:ba0870ec8714 | 3 | namespace SimpleTaskScheduler { |
| dwini | 0:ba0870ec8714 | 4 | |
| dwini | 0:ba0870ec8714 | 5 | void PeriodicTask::run(void) { |
| dwini | 0:ba0870ec8714 | 6 | if (state == SHOULD_RUN) { |
| dwini | 0:ba0870ec8714 | 7 | state = RUNNING; |
| dwini | 0:ba0870ec8714 | 8 | this->callback.call(); |
| dwini | 0:ba0870ec8714 | 9 | state = WAITING; |
| dwini | 0:ba0870ec8714 | 10 | } |
| dwini | 0:ba0870ec8714 | 11 | } |
| dwini | 0:ba0870ec8714 | 12 | |
| dwini | 0:ba0870ec8714 | 13 | void PeriodicTask::tick(void) { |
| dwini | 0:ba0870ec8714 | 14 | // Following can mess with your day if your task is long and periodic periodic |
| dwini | 0:ba0870ec8714 | 15 | //period is small. |
| dwini | 0:ba0870ec8714 | 16 | state = SHOULD_RUN; |
| dwini | 0:ba0870ec8714 | 17 | } |
| dwini | 0:ba0870ec8714 | 18 | }; |