35 #ifndef _BLAZE_UTIL_THREADPOOL_THREADPOOL_H_
36 #define _BLAZE_UTIL_THREADPOOL_THREADPOOL_H_
43 #include <boost/bind.hpp>
44 #include <boost/thread/condition.hpp>
45 #include <boost/thread/mutex.hpp>
239 typedef Mutex::scoped_lock
Lock;
262 inline size_t size()
const;
263 inline size_t active()
const;
264 inline size_t ready()
const;
271 template<
typename Callable >
274 template<
typename Callable,
typename A1 >
275 void schedule( Callable func, A1 a1 );
277 template<
typename Callable,
typename A1,
typename A2 >
278 void schedule( Callable func, A1 a1, A2 a2 );
280 template<
typename Callable,
typename A1,
typename A2,
typename A3 >
281 void schedule( Callable func, A1 a1, A2 a2, A3 a3 );
283 template<
typename Callable,
typename A1,
typename A2,
typename A3,
typename A4 >
284 void schedule( Callable func, A1 a1, A2 a2, A3 a3, A4 a4 );
286 template<
typename Callable,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5 >
287 void schedule( Callable func, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 );
411 template<
typename Callable >
431 template<
typename Callable
453 template<
typename Callable
477 template<
typename Callable
503 template<
typename Callable
531 template<
typename Callable
ThreadPool(size_t n)
Constructor for the ThreadPool class.
Definition: ThreadPool.cpp:69
boost::condition_variable Condition
Condition variable type.
Definition: ThreadPool.h:240
void schedule(Callable func)
Scheduling the given zero argument function/functor for execution.
Definition: ThreadPool.h:412
Threads threads_
The threads contained in the thread pool.
Definition: ThreadPool.h:317
Base class for non-copyable class instances.
size_t size() const
Returns the current size of the thread pool.
Definition: ThreadPool.h:360
TaskQueue taskqueue_
Task queue for the scheduled tasks.
Definition: ThreadPool.h:318
volatile size_t expected_
Expected number of threads in the thread pool.
Definition: ThreadPool.h:313
Implementation of a vector for (polymorphic) pointers.
Task queue for the thread pool.
Condition waitForTask_
Wait condition for idle threads.
Definition: ThreadPool.h:320
void createThread()
Adding a new thread to the thread pool.
Definition: ThreadPool.cpp:232
Header file for the Thread class.
void wait()
Waiting for all scheduled tasks to be completed.
Definition: ThreadPool.cpp:192
Base class for non-copyable class instances.The NonCopyable class is intended to work as a base class...
Definition: NonCopyable.h:63
size_t ready() const
Returns the number of currently ready/inactive threads.
Definition: ThreadPool.h:386
bool isEmpty() const
Returns whether any tasks are scheduled for execution.
Definition: ThreadPool.h:347
threadpool::TaskQueue TaskQueue
Type of the task queue.
Definition: ThreadPool.h:237
Implementation of a single thread of execution.
Definition: Thread.h:200
bool executeTask()
Executing a scheduled task.
Definition: ThreadPool.cpp:251
volatile size_t total_
Total number of threads in the thread pool.
Definition: ThreadPool.h:312
Mutex::scoped_lock Lock
Type of a locking object.
Definition: ThreadPool.h:239
volatile size_t active_
Number of currently active/busy threads.
Definition: ThreadPool.h:316
void resize(size_t n)
Changes the total number of threads in the thread pool.
Definition: ThreadPool.cpp:149
~ThreadPool()
Destructor for the ThreadPool class.
Definition: ThreadPool.cpp:98
Header file for the Task base class.
Condition waitForThread_
Wait condition for the thread management.
Definition: ThreadPool.h:321
void push(Task task)
Adding a task to the end of the task queue.
Definition: TaskQueue.h:225
Task queue for the thread pool.The TaskQueue class represents the internal task container of a thread...
Definition: TaskQueue.h:64
size_t active() const
Returns the number of currently active/busy threads.
Definition: ThreadPool.h:373
Header file for basic type definitions.
void clear()
Removing all scheduled tasks from the thread pool.
Definition: ThreadPool.cpp:211
PtrVector< Thread > Threads
Type of the thread container.
Definition: ThreadPool.h:236
bool isEmpty() const
Returns true if the task queue has no elements.
Definition: TaskQueue.h:202
Mutex mutex_
Synchronization mutex.
Definition: ThreadPool.h:319
Implementation of a thread pool.
Definition: ThreadPool.h:232
boost::mutex Mutex
Type of the mutex.
Definition: ThreadPool.h:238