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:
11:df18df016d7e
--- a/jobService.h	Tue Jul 11 23:12:54 2017 +0000
+++ b/jobService.h	Thu Jul 13 20:01:07 2017 +0000
@@ -4,7 +4,7 @@
 
 namespace JobScheduler {
     
-    typedef void (jobFunc)(void);
+    typedef void (jobFunc)(void *context);
     
     // Error type uses zero to indicate no Error.
     // Any other value is an error with error code.
@@ -17,10 +17,12 @@
     */
     class JobType {
         public:
-            JobType(int jobTypeID, jobFunc *job)
-            : _jobTypeID(jobTypeID), _job(job) {}
+            JobType(int jobTypeID, jobFunc *job, void *context)
+            : _jobTypeID(jobTypeID), _job(job), _context(context) {}
 
-            jobFunc *Job();
+            void RunJob() {
+                _job(_context);
+            }
 
             bool AscendingExcl(JobType *d2);
             bool IsEqual(JobType *d2);
@@ -28,6 +30,7 @@
         private:
             int _jobTypeID;
             jobFunc *_job;
+            void *_context;
     };
     
     /**
@@ -42,13 +45,13 @@
             Register associates jobTypeID with job and stores association.
             @returns Error if failed to register.
             */
-            Error Register(int jobTypeID, jobFunc *job);
+            Error Register(int jobTypeID, jobFunc *job, void *context);
             
             /**
             GetJob returns job function based on jobTypeID.
             @returns NULL if job is not found.
             */
-            jobFunc* GetJob(int jobTypeID);
+            JobType* GetJob(int jobTypeID);
         
         private:
             /*