46#include <condition_variable>
115 void init(
size_t num_threads);
141 std::deque<worker_thread_base*>
tasks;
Implements a pool of threads, and can queue tasks.
std::vector< std::thread > threads
static void start_thread(thread_pool *tp)
A static function to start a thread.
std::condition_variable condition
~thread_pool()
default destructor
std::deque< worker_thread_base * > tasks
void add_task(worker_thread_base *task)
Adds a task to the thread pool.
void init(size_t num_threads)
Initializes the thread pool.
size_t get_num_threads()
Returns the number of threads in the thread pool.
thread_pool()
default constructor
A base object for queuing tasks in the thread_pool.
virtual void execute()=0
Derived functions must define this function to execute its work.
virtual ~worker_thread_base()
virtual construction is a necessity to deconstruct derived objects.