16#ifndef SIMICS_SYSTEMC_THREAD_POOL_H
17#define SIMICS_SYSTEMC_THREAD_POOL_H
25#include <unordered_map>
67 void thread_function();
70 sc_core::sc_process_handle process_handle_;
71 sc_core::sc_thread_process *thread_process_;
72 sc_core::sc_event wait_for_work_;
77template<
class TThread = Thread>
94 void allocateThread() {
95 TThread *t =
new TThread;
100 virtual void run(ThreadInterface *
call) {
103 virtual void block(ThreadInterface *
call) {
106 virtual void finish(ThreadInterface *
call) {
107 auto it = active_.find(
call);
108 ASSERT(it != active_.end());
109 it->second->finish(
call);
112 it->second =
nullptr;
115 virtual void exception(ThreadInterface *
call) {
119 virtual iface::SimulationInterface *simulation(ThreadInterface *
call) {
120 return active_[
call]->simulation(
call);
123 std::queue<ThreadInterface *> idle_;
124 std::unordered_map<ThreadInterface *, ThreadCallbackInterface *> active_;
Definition: kernel_state_modifier.h:30
Definition: thread_pool.h:33
virtual iface::SimulationInterface * simulation(ThreadInterface *call)=0
virtual void exception(ThreadInterface *call)=0
virtual ~ThreadCallbackInterface()
Definition: thread_pool.h:35
virtual void block(ThreadInterface *call)=0
virtual void run(ThreadInterface *call)=0
virtual void finish(ThreadInterface *call)=0
Definition: thread_pool.h:44
virtual CallReturn call(ThreadCallbackInterface *cb)=0
virtual ~ThreadInterface()
Definition: thread_pool.h:52
CallReturn
Definition: thread_pool.h:46
@ CALL_RETURN_TERMINATED
Definition: thread_pool.h:49
@ CALL_RETURN_WAITING
Definition: thread_pool.h:48
@ CALL_RETURN_ERROR_IN_USE
Definition: thread_pool.h:50
@ CALL_RETURN_FINISHED
Definition: thread_pool.h:47
Definition: thread_pool.h:78
virtual CallReturn call(ThreadCallbackInterface *cb)
Definition: thread_pool.h:81
Definition: thread_pool.h:57
virtual CallReturn call(ThreadCallbackInterface *cb)
virtual const char * thread_name()
Interface to the SystemC simulation.
Definition: simulation_interface.h:27
Definition: pci_bus_interface.h:24