job scheduler works with run once and run periodic schedules. Stop logic is not fully thought through.
Dependents: JobSchedulerDemo Borsch
Diff: scheduler.h
- Revision:
- 3:f08f55827736
- Parent:
- 2:9bf5366ad5a2
- Child:
- 4:78bcd5a675e1
--- a/scheduler.h Tue Jul 11 20:35:19 2017 +0000 +++ b/scheduler.h Tue Jul 11 21:47:53 2017 +0000 @@ -11,8 +11,6 @@ typedef int ActionType; - const ActionType JobAddAT(1); - /** Declares concept of the schedule. For example, run once, run periodically, run at the top of the hour, @@ -53,8 +51,8 @@ template<typename T> struct Response : ResBase { - T Data; - Response(Error err, T data) : ResBase(err), Data(data) {} + T data; + Response(Error anError, T aData) : ResBase(anError), data(aData) {} }; struct Action { @@ -70,11 +68,11 @@ public: Job(JobTypeID typeID, ISchedule *schedule, IJobData *data) - : _id(0), _typeID(typeID), _schedule(schedule), _data(data) {}; + : _id(0), _typeID(typeID), _schedule(schedule), _data(data) {} JobID GetID() const { return _id; - }; + } void Init(JobID id) { _id = id; @@ -82,7 +80,11 @@ JobTypeID GetTypeID() const { return _typeID; - }; + } + + ISchedule *GetSchedule() { + return _schedule; + } private: JobID _id; @@ -102,6 +104,10 @@ return _time; } + void SetTime(time_t time) { + _time = time; + } + Job* GetJob() { return &_job; } @@ -139,6 +145,7 @@ void updateHandler(); void process(Action *action); + void onWakeOnce(); private: Thread _updater; bool _quit; @@ -146,7 +153,6 @@ JobID _nextJobID; /** _actions contains incoming action queue to handle. */ Queue<Action, 5> _actions; - LinkedList<Appointment> _timeline; - + LinkedList<Appointment> _timeline; }; } \ No newline at end of file