job scheduler works with run once and run periodic schedules. Stop logic is not fully thought through.
Dependents: JobSchedulerDemo Borsch
jobService.cpp
- Committer:
- sgnezdov
- Date:
- 2017-07-13
- Revision:
- 9:ee21cd055a97
- Parent:
- 0:806403f3d0d1
- Child:
- 10:8cff30b5b90d
File content as of revision 9:ee21cd055a97:
#include "jobService.h" namespace JobScheduler { bool JobType::AscendingExcl(JobType *j2) { return this->_jobTypeID < j2->_jobTypeID; } bool JobType::IsEqual(JobType *j2) { return this->_jobTypeID == j2->_jobTypeID; } bool jtAscending(JobType *j1, JobType *j2) { return j1->AscendingExcl(j2); } bool jtIsEqual(JobType *j1, JobType *j2) { return j1->IsEqual(j2); } Error JobService::Register(int jobTypeID, jobFunc *job, void *context) { JobType *jt = new JobType(jobTypeID, job, context); node<JobType> *tmp = _jobs.insertOrdered(jt, jtAscending); if (NULL == tmp) { error("[JobService::Register] failed to insertOrdered"); return Error(1); } return NoError; } JobType* JobService::GetJob(int jobTypeID) { JobType search = JobType(jobTypeID, NULL, NULL); node<JobType> *found = _jobs.pop(&search, jtIsEqual); if (found == NULL) { return NULL; } return found->data; } } // end of namespace