job scheduler works with run once and run periodic schedules. Stop logic is not fully thought through.

Dependencies:   LinkedList

Dependents:   JobSchedulerDemo Borsch

Revision:
9:ee21cd055a97
Parent:
0:806403f3d0d1
Child:
10:8cff30b5b90d
--- a/jobService.cpp	Tue Jul 11 23:12:54 2017 +0000
+++ b/jobService.cpp	Thu Jul 13 20:01:07 2017 +0000
@@ -2,11 +2,6 @@
 
 namespace JobScheduler {
 
-jobFunc* JobType::Job()
-{
-    return this->_job;
-}
-
 bool JobType::AscendingExcl(JobType *j2) 
 {
     return this->_jobTypeID < j2->_jobTypeID;
@@ -27,9 +22,9 @@
     return j1->IsEqual(j2);
 }
 
-Error JobService::Register(int jobTypeID, jobFunc *job)
+Error JobService::Register(int jobTypeID, jobFunc *job, void *context)
 {
-    JobType *jt = new JobType(jobTypeID, job);
+    JobType *jt = new JobType(jobTypeID, job, context);
     node<JobType> *tmp = _jobs.insertOrdered(jt, jtAscending);
     if (NULL == tmp) {
         error("[JobService::Register] failed to insertOrdered");
@@ -38,14 +33,14 @@
     return NoError; 
 }
 
-jobFunc* JobService::GetJob(int jobTypeID)
+JobType* JobService::GetJob(int jobTypeID)
 {
-    JobType search = JobType(jobTypeID, NULL);
+    JobType search = JobType(jobTypeID, NULL, NULL);
     node<JobType> *found = _jobs.pop(&search, jtIsEqual);
     if (found == NULL) {
         return NULL;
     }
-    return found->data->Job();
+    return found->data;
 }
 
 } // end of namespace
\ No newline at end of file