A thread pool that dispatches tasks added in the queue to a number of worker threads.
More...
|
| SysThreadPool (const unsigned int &max_thread_count) |
|
void | add (SysThreadPoolTask &item, const bool &auto_delete=true, const bool &blocking=true) |
| Add a new task to the pool and starts it if worker threads are are available.
|
|
bool | wait_until_completed () |
| Wait until all tasks have been dispatched and completed by workers.
|
|
void | shutdown () |
| Purge all unprocessed tasks and kill all threads.
|
|
const unsigned int & | get_max_thread_count () const |
| return the number of worker thread allocated for the pool
|
|
const bool & | is_running () const |
| return if the pool is currently running. A running pool has necessarely tasks beeing processed by workers. Typically after a shutdown(), is_running() returns false
|
|
bool | is_kindof (const CoreBaseObject &object) const |
|
virtual size_t | get_memory_size () const |
|
CoreString | get_class_info_name () const |
|
const unsigned long & | get_class_info_id () const |
|
virtual bool | is_kindof (const CoreClassInfo &cinfo) const |
|
virtual const CoreClassInfo & | get_class_info () const |
|
template<class T > |
T * | cast () |
|
template<class T > |
const T * | cast () const |
|
bool | is_kindof (const CoreClassInfo &cinfo) const |
|
A thread pool that dispatches tasks added in the queue to a number of worker threads.
Within a thread pool, there are many more pending tasks that the number of worker threads. As soon a worker completes its tasks, it requests the next available task from the task queue if any available. If there are no pending tasks the workers simply sleeps and waits for more tasks to be dispatched.