#include <OW_ThreadPool.hpp>
Inheritance diagram for OW_NAMESPACE::ThreadPool:
Public Types | |
enum | PoolType { FIXED_SIZE, DYNAMIC_SIZE, DYNAMIC_SIZE_NO_QUEUE } |
enum | { UNLIMITED_QUEUE_SIZE = 0 } |
enum | EShutdownQueueFlag { E_DISCARD_WORK_IN_QUEUE, E_FINISH_WORK_IN_QUEUE } |
Public Member Functions | |
ThreadPool (PoolType poolType, UInt32 numThreads, UInt32 maxQueueSize, const LoggerRef &logger=LoggerRef(), const String &poolName="") | |
Constructor. | |
bool | addWork (const RunnableRef &work) |
Add an RunnableRef for the pool to execute. | |
bool | tryAddWork (const RunnableRef &work) |
Add an RunnableRef for the pool to execute. | |
void | shutdown (EShutdownQueueFlag finishWorkInQueue=E_FINISH_WORK_IN_QUEUE, int timeoutSecs=-1) |
Instruct all threads to exit and stop working. | |
void | waitForEmptyQueue () |
Wait for the queue to empty out. | |
~ThreadPool () | |
Destructor. | |
ThreadPool (const ThreadPool &x) | |
ThreadPool & | operator= (const ThreadPool &x) |
Private Attributes | |
IntrusiveReference< ThreadPoolImpl > | m_impl |
There is a queue maintained of work to do. As each thread in the group is available it will get it's next task from the head of the queue. The queue can have a maximum size limit or can be of unlimited size.
This class is freely copyable. All copies reference the same underlying implementation. This class is thread safe.
Definition at line 59 of file OW_ThreadPool.hpp.
|
Definition at line 68 of file OW_ThreadPool.hpp. |
|
Definition at line 114 of file OW_ThreadPool.hpp. |
|
Definition at line 62 of file OW_ThreadPool.hpp. |
|
Constructor.
Definition at line 627 of file OW_ThreadPool.cpp. References DYNAMIC_SIZE, DYNAMIC_SIZE_NO_QUEUE, FIXED_SIZE, logger, and m_impl. |
|
Destructor. This will call shutdown(E_DISCARD_WORK_IN_QUEUE, 1) when the last copy is destroyed Definition at line 668 of file OW_ThreadPool.cpp. |
|
Definition at line 672 of file OW_ThreadPool.cpp. |
|
Add an RunnableRef for the pool to execute. If the queue is full, this call will block until there is space in the queue.
Definition at line 648 of file OW_ThreadPool.cpp. References m_impl. |
|
Definition at line 678 of file OW_ThreadPool.cpp. References m_impl. |
|
Instruct all threads to exit and stop working. After shutdown() is called, addWork() and tryAddWork() will return false.
Definition at line 658 of file OW_ThreadPool.cpp. References m_impl. |
|
Add an RunnableRef for the pool to execute. If the queue is full, this call will *not* block.
Definition at line 653 of file OW_ThreadPool.cpp. References m_impl. |
|
Wait for the queue to empty out.
Definition at line 663 of file OW_ThreadPool.cpp. References m_impl. |
|
Definition at line 153 of file OW_ThreadPool.hpp. Referenced by addWork(), operator=(), shutdown(), ThreadPool(), tryAddWork(), and waitForEmptyQueue(). |