Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00013 #ifndef THREAD_POOL_BASE_H
00014 #define THREAD_POOL_BASE_H
00015
00016 #include <boost/thread.hpp>
00017 #include <systemc>
00018 #include "sync-task.h"
00019 #include "utils/atomic-variable.h"
00020
00024 class thread_pool_base {
00025 public:
00026 static void process_tasks(thread_pool_base *p,
00027 sc_core::sc_process_b *sc_process);
00028 virtual void queue(sync_task *r, sc_core::sc_process_b *current = NULL) = 0;
00029 int get_nb_threads() const {return m_thread_array.size();}
00030 thread_pool_base();
00031 virtual ~thread_pool_base() {}
00032 private:
00033 virtual sync_task *pop_task(sc_core::sc_process_b *sc_process) = 0;
00034 protected:
00035 void terminate_simulation() {
00036 stop_all_threads();
00037 }
00038
00039 virtual void stop_all_threads();
00040
00041 typedef boost::thread *thread_ptr;
00042 std::vector<thread_ptr> m_thread_array;
00043 thread_ptr add_thread(sc_core::sc_process_b *sc_process = NULL);
00044 static atomic_variable<int> m_index;
00045 };
00046
00047 #endif // THREAD_POOL_BASE_H