Sergei G
/
JobSchedulerDemo
run once and run periodic example work
Diff: source/main.cpp
- Revision:
- 0:728722f45131
- Child:
- 2:4fe42e3bafe4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/main.cpp Tue Jul 11 00:16:23 2017 +0000 @@ -0,0 +1,51 @@ +#include "mbed.h" +#include "scheduler.h" +#include "LinkedList.h" +#include "jobService.h" + +void job1() +{ + printf("Job 1\n"); +} + +void runScheduler() +{ + JobScheduler::JobService js; + JobScheduler::Scheduler scheduler(&js); + + js.Register(1, job1); + + scheduler.Start(); + scheduler.JobAdd(1); + wait(5); + scheduler.Stop(); + scheduler.WaitToStop(); +} + +void useTime() +{ + //set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 +// while (true) { +// time_t seconds = time(NULL); +// +// printf("Time as seconds since January 1, 1970 = %d\n", seconds); +// +// printf("Time as a basic string = %s", ctime(&seconds)); +// +// char buffer[32]; +// strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); +// printf("Time as a custom formatted string = %s", buffer); +// +// wait(1); +// } +} + +int main() +{ + printf("\nJob Scheduler Demo\n"); + runScheduler(); + printf("done\n"); + + exit(0); +} +