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 9:27e0a0dd98d1, committed 2017-08-02
- Comitter:
- sgnezdov
- Date:
- Wed Aug 02 22:04:02 2017 +0000
- Parent:
- 8:8a65353ec8f3
- Commit message:
- added JobList testing
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 |
diff -r 8a65353ec8f3 -r 27e0a0dd98d1 JobScheduler.lib --- a/JobScheduler.lib Fri Jul 14 00:01:13 2017 +0000 +++ b/JobScheduler.lib Wed Aug 02 22:04:02 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sgnezdov/code/JobScheduler/#df18df016d7e +https://developer.mbed.org/users/sgnezdov/code/JobScheduler/#6b8fa5dff770
diff -r 8a65353ec8f3 -r 27e0a0dd98d1 source/main.cpp
--- a/source/main.cpp Fri Jul 14 00:01:13 2017 +0000
+++ b/source/main.cpp Wed Aug 02 22:04:02 2017 +0000
@@ -28,6 +28,21 @@
printf("Job B\n");
}
+void printJobs(JobScheduler::Scheduler& scheduler)
+{
+ LinkedList<JobScheduler::Job> jobs;
+ scheduler.JobList(jobs);
+ printf(" Job List:\n");
+ node<JobScheduler::Job>* jn = jobs.pop(1);
+ while (jn != NULL) {
+ printf("Job ID: %d\n", jn->data->GetID());
+ jobs.remove(1);
+ jn = jobs.pop(1);
+ }
+ printf(" Job List Completed\n");
+}
+
+
void runScheduler()
{
/* Setup tracing */
@@ -77,18 +92,25 @@
time_t nowSecs = time(NULL);
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);
+
+ printJobs(scheduler);
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);
+ printJobs(scheduler);
wait(10);
+ printJobs(scheduler);
scheduler.Stop();
scheduler.WaitToStop();
}
int main()
{
+ Serial pc(USBTX, USBRX);
+ pc.baud(115200);
+
printf("\nJob Scheduler Demo\n");
runScheduler();
printf("done\n");