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.
Revision 6:b0bca03d9f3a, committed 2017-07-11
- Comitter:
- sgnezdov
- Date:
- Tue Jul 11 23:13:07 2017 +0000
- Parent:
- 5:79cbf6d8b5f0
- Child:
- 7:3513a1ae8fb7
- Commit message:
- added periodic job and it works
Changed in this revision
| JobScheduler.lib | Show annotated file Show diff for this revision Revisions of this file |
| source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/JobScheduler.lib Tue Jul 11 22:35:51 2017 +0000 +++ b/JobScheduler.lib Tue Jul 11 23:13:07 2017 +0000 @@ -1,1 +1,1 @@ -JobScheduler#d8f69ac330f2 +JobScheduler#4ead1f4ab741
--- a/source/main.cpp Tue Jul 11 22:35:51 2017 +0000
+++ b/source/main.cpp Tue Jul 11 23:13:07 2017 +0000
@@ -4,9 +4,14 @@
#include "jobService.h"
#include "schedules.h"
-void job1()
+void jobA()
{
- printf("Job 1\n");
+ printf("Job A\n");
+}
+
+void jobB()
+{
+ printf("Job B\n");
}
void runScheduler()
@@ -14,13 +19,19 @@
JobScheduler::JobService js;
JobScheduler::Scheduler scheduler(&js);
- js.Register(1, job1);
+ js.Register(1, jobA);
+ js.Register(2, jobB);
scheduler.Start();
time_t nowSecs = time(NULL);
- JobScheduler::Response<JobScheduler::JobID> res = scheduler.JobAdd(1, new JobScheduler::RunOnceSchedule(nowSecs + 5), NULL);
- printf("job add response error: %d, jobID: %d\n", res.error, res.data);
+ JobScheduler::Response<JobScheduler::JobID> res = scheduler.JobAdd(1, new JobScheduler::RunOnceSchedule(nowSecs + 2), NULL);
+ printf("job A add response error: %d, jobID: %d\n", res.error, res.data);
+ wait(5);
+
+ printf("periodic with 2 sec period and limit 3\n");
+ res = scheduler.JobAdd(2, new JobScheduler::RunPeriodicSchedule(2, 3), NULL);
+ printf("job B add response error: %d, jobID: %d\n", res.error, res.data);
wait(10);
scheduler.Stop();
scheduler.WaitToStop();