Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: JobSchedulerDemo Borsch
Diff: scheduler.cpp
- Revision:
- 4:78bcd5a675e1
- Parent:
- 3:f08f55827736
- Child:
- 5:d8f69ac330f2
diff -r f08f55827736 -r 78bcd5a675e1 scheduler.cpp
--- a/scheduler.cpp Tue Jul 11 21:47:53 2017 +0000
+++ b/scheduler.cpp Tue Jul 11 22:05:12 2017 +0000
@@ -37,9 +37,15 @@
Scheduler *self = static_cast<Scheduler*>(thisPointer);
self->updateHandler();
}
+
+ void Scheduler::runAdapter(void *thisPointer) {
+ Scheduler *self = static_cast<Scheduler*>(thisPointer);
+ self->runHandler();
+ }
void Scheduler::Start() {
_updater.start(callback(Scheduler::updateAdapter, this));
+ _runner.start(callback(Scheduler::runAdapter, this));
}
void Scheduler::Stop() {
@@ -49,6 +55,7 @@
void Scheduler::WaitToStop() {
_updater.join();
+ _runner.join();
}
Response<JobID> Scheduler::JobAdd(JobTypeID jobTID, ISchedule *schedule, IJobData *data) {
@@ -58,7 +65,7 @@
return Response<JobID>(1, 0);
}
JobAddReq req(apt);
- _actions.put(&req);
+ _updates.put(&req);
// default is wait forever
osEvent evt = req.resQueue.get();
if (evt.status == osEventMessage) {
@@ -83,14 +90,14 @@
static JobRunReq jobRunReq;
void Scheduler::onWakeOnce()
{
- _actions.put(&jobRunReq);
+ _updates.put(&jobRunReq);
}
void Scheduler::updateHandler() {
while (!_quit) {
printf("[Scheduler::updateHandler] waiting for action\n");
// wait forever ...
- osEvent evt = _actions.get();
+ osEvent evt = _updates.get();
if (evt.status == osEventMessage) {
printf("[Scheduler::updateHandler] process action\n");
this->process((Action*)evt.value.p);
@@ -147,8 +154,24 @@
// process job
printf("[Scheduler::process] running job ID %d\n", wakeJob->GetID());
_timeline.remove(1);
+ _runs.put(wakeApt);
}
+ }
+
+ void Scheduler::runHandler() {
+ while (!_quit) {
+ printf("[Scheduler::runHandler] waiting for action\n");
+ // wait forever ...
+ osEvent evt = _runs.get();
+ if (evt.status == osEventMessage) {
+ printf("[Scheduler::runHandler] run action\n");
+ Appointment *apt = (Appointment*)evt.value.p;
+ printf("[Scheduler::runHandler] TBD: RUN, RESCHEDULE\n");
+ } else {
+ printf("[Scheduler::runHandler] NOT osEventMessage\n");
+ }
+ }
+ }
- }
}
\ No newline at end of file