41 friend class WorkerThread;
44 ThreadPool(
unsigned size);
47 bool enqueue(
Worker* worker);
49 unsigned max_size()
const {
return m_size; }
51 void set_max_size(
unsigned size);
53 void set_keep_alive(
unsigned millisec);
55 unsigned size()
const;
57 unsigned queue_size()
const;
58 bool is_queue_empty()
const;
60 bool wait_empty_for(
unsigned millisec);
64 bool is_suspended()
const;
69 bool is_stopped()
const;
75 unsigned m_waitingCount;
76 volatile bool m_stopped;
77 volatile bool m_suspended;
78 volatile bool m_empty;
80 std::queue<Worker*> m_queue;
81 std::set<WorkerThread*> m_pool;
82 mutable Mutex m_mutex;
87 Worker* pop_queue(WorkerThread* _thread);
88 void wait_queue(WorkerThread* _thread);
89 void start_thread(WorkerThread* _thread);
90 void finalize_thread(WorkerThread* _thread);