Changeset View
Changeset View
Standalone View
Standalone View
src/scheduler.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | void CScheduler::schedule(CScheduler::Function f, | ||||
boost::unique_lock<boost::mutex> lock(newTaskMutex); | boost::unique_lock<boost::mutex> lock(newTaskMutex); | ||||
taskQueue.insert(std::make_pair(t, f)); | taskQueue.insert(std::make_pair(t, f)); | ||||
} | } | ||||
newTaskScheduled.notify_one(); | newTaskScheduled.notify_one(); | ||||
} | } | ||||
void CScheduler::scheduleFromNow(CScheduler::Function f, | void CScheduler::scheduleFromNow(CScheduler::Function f, | ||||
int64_t deltaMilliSeconds) { | int64_t deltaMilliSeconds) { | ||||
schedule(f, | schedule(f, boost::chrono::system_clock::now() + | ||||
boost::chrono::system_clock::now() + | |||||
boost::chrono::milliseconds(deltaMilliSeconds)); | boost::chrono::milliseconds(deltaMilliSeconds)); | ||||
} | } | ||||
static void Repeat(CScheduler *s, CScheduler::Predicate p, | static void Repeat(CScheduler *s, CScheduler::Predicate p, | ||||
int64_t deltaMilliSeconds) { | int64_t deltaMilliSeconds) { | ||||
if (p()) { | if (p()) { | ||||
s->scheduleFromNow(boost::bind(&Repeat, s, p, deltaMilliSeconds), | s->scheduleFromNow(boost::bind(&Repeat, s, p, deltaMilliSeconds), | ||||
deltaMilliSeconds); | deltaMilliSeconds); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |