2021-02-18 17:21:25 -05:00
|
|
|
#ifndef SCHED_HPP
|
|
|
|
|
#define SCHED_HPP
|
|
|
|
|
|
2022-02-23 23:08:28 -05:00
|
|
|
#include "wrap-set.hpp"
|
|
|
|
|
|
2021-03-16 12:19:37 -04:00
|
|
|
#include "streambuffer.hpp"
|
2021-02-18 17:21:25 -05:00
|
|
|
|
2022-02-23 23:08:28 -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
|
|
|
|
2022-02-24 02:17:41 -05:00
|
|
|
eng::string debug_string() const;
|
2021-02-18 17:21:25 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Schedule {
|
|
|
|
|
private:
|
2022-02-24 02:17:41 -05:00
|
|
|
eng::set<SchedEntry> schedule_;
|
2021-02-18 17:21:25 -05:00
|
|
|
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();
|
2022-02-24 02:17:41 -05:00
|
|
|
eng::string debug_string();
|
2021-03-16 12:19:37 -04:00
|
|
|
|
|
|
|
|
void serialize(StreamBuffer *sb);
|
|
|
|
|
void deserialize(StreamBuffer *sb);
|
2021-02-18 17:21:25 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SCHED_HPP
|
|
|
|
|
|