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

49 lines
999 B
C++
Raw Normal View History

2021-02-18 17:21:25 -05:00
#ifndef SCHED_HPP
#define SCHED_HPP
#include "wrap-set.hpp"
#include "streambuffer.hpp"
2021-02-18 17:21:25 -05:00
#include <cstdint>
2021-02-18 17:21:25 -05:00
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;
2021-07-30 13:57:03 -04:00
std::string debug_string() const;
2021-02-18 17:21:25 -05:00
};
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;
2021-07-30 13:57:03 -04:00
bool empty() const { return schedule_.empty(); }
2021-02-18 17:21:25 -05:00
SchedEntry pop();
2021-07-30 13:57:03 -04:00
std::string debug_string();
void serialize(StreamBuffer *sb);
void deserialize(StreamBuffer *sb);
2021-02-18 17:21:25 -05:00
};
#endif // SCHED_HPP