Added class Schedule for threads
This commit is contained in:
39
luprex/core/cpp/sched.hpp
Normal file
39
luprex/core/cpp/sched.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef SCHED_HPP
|
||||
#define SCHED_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
class SchedEntry {
|
||||
private:
|
||||
friend class Schedule;
|
||||
|
||||
int64_t clock_;
|
||||
int64_t thread_id_;
|
||||
int64_t place_id_;
|
||||
|
||||
public:
|
||||
int64_t clock() const { return clock_; }
|
||||
int64_t thread_id() const { return thread_id_; }
|
||||
int64_t place_id() const { return place_id_; }
|
||||
|
||||
SchedEntry(int64_t clk, int64_t thid, int64_t plid) {
|
||||
clock_ = clk;
|
||||
thread_id_ = thid;
|
||||
place_id_ = plid;
|
||||
}
|
||||
|
||||
bool operator < (const SchedEntry &other) const;
|
||||
};
|
||||
|
||||
class Schedule {
|
||||
private:
|
||||
std::set<SchedEntry> schedule_;
|
||||
public:
|
||||
void add(int64_t clk, int64_t thid, int64_t plid);
|
||||
bool ready(int64_t clk) const;
|
||||
SchedEntry pop();
|
||||
};
|
||||
|
||||
#endif // SCHED_HPP
|
||||
|
||||
Reference in New Issue
Block a user