Files
integration/luprex/core/cpp/sched.cpp

28 lines
773 B
C++
Raw Normal View History

2021-02-18 17:21:25 -05:00
#include "sched.hpp"
bool SchedEntry::operator < (const SchedEntry &other) const {
if (clock_ < other.clock_) return true;
if (clock_ > other.clock_) return false;
if (thread_id_ < other.thread_id_) return true;
if (thread_id_ > other.thread_id_) return false;
if (place_id_ < other.place_id_) return true;
if (place_id_ > other.place_id_) return false;
return false;
}
void Schedule::add(int64_t clk, int64_t thid, int64_t plid) {
schedule_.insert(SchedEntry(clk, thid, plid));
}
bool Schedule::ready(int64_t clk) const {
return (!schedule_.empty()) && (schedule_.begin()->clock() <= clk);
}
SchedEntry Schedule::pop() {
SchedEntry result = *schedule_.begin();
schedule_.erase(schedule_.begin());
return result;
}