run once and run periodic example work

Dependencies:   JobScheduler

source/main.cpp

Committer:
sgnezdov
Date:
2017-07-11
Revision:
0:728722f45131
Child:
2:4fe42e3bafe4

File content as of revision 0:728722f45131:

#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);
}