#include <cthreadpool.h>
Classes | |
class | Task |
class | Thread |
Public Member Functions | |
CThreadPool (int numThreads, int queueLen) | |
lock for m_threads | |
~CThreadPool () | |
void | queue (Task *t) |
void | stop () |
Protected Member Functions | |
Task * | getTask () |
void | threadDone (CThreadPool::Thread *thread) |
Private Types | |
typedef std::list< Thread * > | threadlist_t |
typedef std::list< Task * > | tasklist_t |
Private Attributes | |
threadlist_t | m_threads |
tasklist_t | m_queue |
int | m_maxQueueLen |
int | m_curQueueLen |
bool | m_running |
sptk::CWaiter | m_queueLock |
sptk::CWaiter | m_tlLock |
Definition at line 35 of file cthreadpool.h.
typedef std::list<Task*> container::CThreadPool::tasklist_t [private] |
Definition at line 60 of file cthreadpool.h.
typedef std::list<Thread*> container::CThreadPool::threadlist_t [private] |
Definition at line 59 of file cthreadpool.h.
container::CThreadPool::CThreadPool | ( | int | numThreads, | |
int | queueLen | |||
) |
container::CThreadPool::~CThreadPool | ( | ) |
Definition at line 40 of file cthreadpool.cpp.
References stop().
CThreadPool::Task * container::CThreadPool::getTask | ( | ) | [protected] |
Called by PooledThread to retrieve next task to process. Blocks if no tasks are available
Definition at line 60 of file cthreadpool.cpp.
References m_curQueueLen, m_queue, m_queueLock, and m_running.
Referenced by container::CThreadPool::CThreadPool::Thread::threadFunction().
void container::CThreadPool::queue | ( | CThreadPool::Task * | t | ) |
Adds task t to the queue. It can block waiting for some other task to Complete, if maxQueueLength is exceeded.
Definition at line 46 of file cthreadpool.cpp.
References m_curQueueLen, m_maxQueueLen, m_queue, and m_queueLock.
Referenced by container::AcceptConnection::operator()().
void container::CThreadPool::stop | ( | ) |
Once this function is called, threads will start receiving NULL tasks and will exit.
Definition at line 116 of file cthreadpool.cpp.
References m_queueLock, m_running, m_threads, and m_tlLock.
Referenced by ~CThreadPool().
void container::CThreadPool::threadDone | ( | CThreadPool::Thread * | thread | ) | [protected] |
Definition at line 132 of file cthreadpool.cpp.
References m_threads, and m_tlLock.
Referenced by container::CThreadPool::CThreadPool::Thread::onThreadExit().
int container::CThreadPool::m_curQueueLen [private] |
int container::CThreadPool::m_maxQueueLen [private] |
tasklist_t container::CThreadPool::m_queue [private] |
sptk::CWaiter container::CThreadPool::m_queueLock [private] |
bool container::CThreadPool::m_running [private] |
Definition at line 66 of file cthreadpool.h.
Referenced by getTask(), stop(), and container::CThreadPool::CThreadPool::Thread::threadFunction().
sptk::CWaiter container::CThreadPool::m_tlLock [private] |