26 std::thread::id m_systemc_thread_id;
28 std::condition_variable cond;
29 std::thread m_worker_thread;
32 bool m_systemc_waiting;
33 bool m_extern_waiting;
36 virtual bool is_sysc_thread()
const;
45 virtual SyncPolicy::Type get_thread_type()
const override {
return SyncPolicy::OS_THREAD; }
48 virtual void start(std::function<
void()>
job =
nullptr)
override;
49 virtual void stop()
override;
52 virtual sc_core::sc_time time_to_sync()
override;
55 void inc(
const sc_core::sc_time&
t)
override;
56 void set(
const sc_core::sc_time&
t)
override;
57 virtual void sync()
override;
58 void reset()
override;
59 sc_core::sc_time get_current_time()
const override;
60 sc_core::sc_time get_local_time()
const override;
63 virtual bool need_sync()
override;
66 enum jobstates { NONE = 0, RUNNING = 1, STOPPED = 2, SYSC_WAITING = 4, EXT_WAITING = 8, ILLEGAL = 12 };
67 std::atomic<jobstates> status;
71 jobstates get_status() {
return (jobstates)(status | (m_systemc_waiting << 2) | (m_extern_waiting << 3)); }
72 std::string get_status_json()
74 std::string s =
"\"name\":\"" + std::string(name()) +
"\"";
75 s = s +
",\"quantum_time\":\"" + std::string(get_local_time().
to_string()) +
"\"";
76 s = s +
",\"local_time\":\"" + std::string(get_current_time().
to_string()) +
"\"";
77 if ((status & (RUNNING | STOPPED)) == NONE) s = s +
",\"state\":\"NONE\"";
78 if (status & RUNNING) s = s +
",\"state\":\"RUNNING\"";
79 if (status & STOPPED) s = s +
",\"state\":\"IDLE\"";
80 if (m_systemc_waiting) s = s +
",\"sc_waiting\":true";
81 if (m_extern_waiting) s = s +
",\"extern_waiting\":true";