Collaboration diagram for Threaded Pools for Request Handling:
|
Classes | |
| class | CThreadPool_Task |
| Abstract class for representing single task executing in pool of threads To use this class in application you should inherit your own class from it and define method Execute() - the main method where all task logic executes. More... | |
| class | CThreadPool |
| Main class implementing functionality of pool of threads. More... | |
| class | CThreadPool_Thread |
| Base class for a thread running inside CThreadPool and executing tasks. More... | |
| class | CThreadPool_Controller |
| Abstract class for controlling the number of threads in pool. More... | |
| class | CThreadPoolException |
| Exception class for all ThreadPool-related classes. More... | |
| struct | SThreadPool_PID_ErrInfo |
| Entry in "error" changing history Information about "error" in some point of time in the past kept in CThreadPool_Control_PID. More... | |
| class | CThreadPool_Controller_PID |
| Default ThreadPool controller based on Proportional-Integral-Derivative algorithm. More... | |
| class | CQueueItemBase |
| CQueueItemBase -- skeleton blocking-queue item, sans actual request. More... | |
| class | CBlockingQueue< TRequest > |
| CBlockingQueue<> -- queue of requests, with efficiently blocking Get(). More... | |
| class | CThreadInPool< TRequest > |
| class | CPoolOfThreads< TRequest > |
| CPoolOfThreads<> -- abstract pool of threads sharing a request queue. More... | |
| class | CStdRequest |
| class | CStdThreadInPool |
| class | CStdPoolOfThreads |
Functions | |
| bool | CThreadPool_Task::IsCancelRequested (void) const |
| Check if cancelation of the task was requested. | |
| EStatus | CThreadPool_Task::GetStatus (void) const |
| Get status of the task. | |
| bool | CThreadPool_Task::IsFinished (void) const |
| Check if task execution has been already finished (successfully or not). | |
| unsigned int | CThreadPool_Task::GetPriority (void) const |
| Get priority of the task. | |
| unsigned int | CThreadPool_Controller::GetMinThreads (void) const |
| Get the minimum number of threads in pool. | |
| unsigned int | CThreadPool_Controller::GetMaxThreads (void) const |
| Get the maximum number of threads in pool. | |
| void | CThreadPool_Controller_PID::SetQueuedTasksThreshold (double threshold) |
| Set maximum number of tasks in queue per each thread The meaning of parameter is only approximate. | |
| double | CThreadPool_Controller_PID::GetQueuedTasksThreshold (void) |
| Get maximum number of tasks in queue per each thread. | |
| void | CThreadPool_Controller_PID::SetTaskMaxQueuedTime (double queued_time) |
| Set maximum time (in seconds) that task can wait in queue for processing until new thread will be launched. | |
| double | CThreadPool_Controller_PID::GetTaskMaxQueuedTime (void) |
| Get maximum time that task can wait in queue for processing until new thread will be launched. | |
| void | CThreadPool_Controller_PID::SetChangeCalcTime (double calc_time) |
| Set the time period (in seconds) for which average speed of changing of waiting tasks number is calculated. | |
| double | CThreadPool_Controller_PID::GetChangeCalcTime (void) |
| Get the time period for which average speed of changing of waiting tasks number is calculated. | |
| void | CThreadPool_Controller_PID::SetChangePredictTime (double predict_time) |
| Set period of prediction of number of tasks in queue The meaning of parameter is only approximate. | |
| double | CThreadPool_Controller_PID::GetChangePredictTime (void) |
| Get period of prediction of number of tasks in queue. | |
| void | CBlockingQueue::CQueueItem::x_SetStatus (EStatus new_status) |
| TItemHandle | CBlockingQueue::Put (const TRequest &request, TUserPriority priority=0, unsigned int timeout_sec=0, unsigned int timeout_nsec=0) |
| Put a request into the queue. | |
| void | CBlockingQueue::WaitForRoom (unsigned int timeout_sec=kMax_UInt, unsigned int timeout_nsec=0) const |
| Wait for room in the queue for up to timeout_sec + timeout_nsec/1E9 seconds. | |
| void | CBlockingQueue::WaitForHunger (unsigned int timeout_sec=kMax_UInt, unsigned int timeout_nsec=0) const |
| Wait for the queue to have waiting readers, for up to timeout_sec + timeout_nsec/1E9 seconds. | |
| TItemHandle | CBlockingQueue::GetHandle (unsigned int timeout_sec=kMax_UInt, unsigned int timeout_nsec=0) |
| Get the first available request from the queue, and return a handle to it. | |
| NCBI_DEPRECATED TRequest | CBlockingQueue::Get (unsigned int timeout_sec=kMax_UInt, unsigned int timeout_nsec=0) |
| Get the first available request from the queue, and return just the request. | |
| size_t | CBlockingQueue::GetSize (void) const |
| Get the number of requests in the queue. | |
| void | CBlockingQueue::SetUserPriority (TItemHandle handle, TUserPriority priority) |
| Adjust a pending request's priority. | |
| void | CBlockingQueue::Withdraw (TItemHandle handle) |
| Withdraw a pending request from consideration. | |
| bool | CBlockingQueue::x_WaitForPredicate (TQueuePredicate pred, CSemaphore &sem, CMutexGuard &guard, unsigned int timeout_sec, unsigned int timeout_nsec) const |
| virtual void * | CThreadInPool::Main (void) |
| Derived (user-created) class must provide a real thread function. | |
| virtual void | CThreadInPool::OnExit (void) |
| Override this to execute finalization code. | |
| virtual void | CThreadInPool::ProcessRequest (TItemHandle handle) |
| Process a request. | |
| CPoolOfThreads::CPoolOfThreads (unsigned int max_threads, unsigned int queue_size, unsigned int spawn_threshold=1, unsigned int max_urgent_threads=kMax_UInt) | |
| Constructor. | |
| virtual | CPoolOfThreads::~CPoolOfThreads (void) |
| Destructor. | |
| void | CPoolOfThreads::Spawn (unsigned int num_threads) |
| Start processing threads. | |
| TItemHandle | CPoolOfThreads::AcceptRequest (const TRequest &request, TUserPriority priority=0, unsigned int timeout_sec=0, unsigned int timeout_nsec=0) |
| Put a request in the queue with a given priority. | |
| TItemHandle | CPoolOfThreads::AcceptUrgentRequest (const TRequest &request, unsigned int timeout_sec=0, unsigned int timeout_nsec=0) |
| Puts a request in the queue with the highest priority It will run a new thread even if the maximum of allowed threads has been already reached. | |
| bool | CPoolOfThreads::HasImmediateRoom (bool urgent=false) const |
| Check whether a new request could be immediately processed. | |
| void | CPoolOfThreads::WaitForRoom (unsigned int timeout_sec=kMax_UInt, unsigned int timeout_nsec=0) |
| Wait for the room in the queue up to timeout_sec + timeout_nsec/1E9 seconds. | |
| TItemHandle | CPoolOfThreads::x_AcceptRequest (const TRequest &req, TUserPriority priority, bool urgent, unsigned int timeout_sec=0, unsigned int timeout_nsec=0) |
| void | CPoolOfThreads::SetUserPriority (TItemHandle handle, TUserPriority priority) |
| Adjust a pending request's priority. | |
|
||||||||||||||||||||||||
|
Put a request in the queue with a given priority.
Definition at line 997 of file thread_pool_old.hpp. References CPoolOfThreads< TRequest >::x_AcceptRequest(). Referenced by CThreadedServer::Run(). |
|
||||||||||||||||||||
|
Puts a request in the queue with the highest priority It will run a new thread even if the maximum of allowed threads has been already reached.
Definition at line 1008 of file thread_pool_old.hpp. References CPoolOfThreads< TRequest >::x_AcceptRequest(). |
|
||||||||||||||||||||||||
|
Constructor.
Definition at line 956 of file thread_pool_old.hpp. References _ASSERT, CPoolOfThreads< TRequest >::kDeltaOffset, CPoolOfThreads< TRequest >::m_Delta, CPoolOfThreads< TRequest >::m_ThreadCount, CPoolOfThreads< TRequest >::m_UrgentThreadCount, and CAtomicCounter::Set(). |
|
||||||||||||||||
|
Get the first available request from the queue, and return just the request. Blocks politely if empty. Waits up to timeout_sec + timeout_nsec/1E9 seconds.
Definition at line 772 of file thread_pool_old.hpp. References CBlockingQueue< TRequest >::GetHandle(). |
|
|
Get the time period for which average speed of changing of waiting tasks number is calculated.
Definition at line 217 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_DerivTime. |
|
|
Get period of prediction of number of tasks in queue.
Definition at line 229 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_DerivCoeff. |
|
||||||||||||||||
|
Get the first available request from the queue, and return a handle to it. Blocks politely if empty. Waits up to timeout_sec + timeout_nsec/1E9 seconds.
Definition at line 728 of file thread_pool_old.hpp. References _VERIFY, set< Key, Compare >::empty(), CBlockingQueue< TRequest >::m_GetSem, CBlockingQueue< TRequest >::m_HungerCnt, CBlockingQueue< TRequest >::m_HungerSem, CBlockingQueue< TRequest >::m_Mutex, CBlockingQueue< TRequest >::m_Queue, CSemaphore::Post(), set< Key, Compare >::size(), CSemaphore::TryWait(), CBlockingQueue< TRequest >::x_GetSemPred(), and CBlockingQueue< TRequest >::x_WaitForPredicate(). Referenced by CBlockingQueue< TRequest >::Get(), and CPrefetchThreadOld::Main(). |
|
|
Get the maximum number of threads in pool.
Definition at line 642 of file thread_pool.hpp. References CThreadPool_Controller::m_MaxThreads. Referenced by CThreadPool_Controller::SetThreadsCount(). |
|
|
Get the minimum number of threads in pool.
Definition at line 636 of file thread_pool.hpp. References CThreadPool_Controller::m_MinThreads. Referenced by CThreadPool_Controller_PID::OnEvent(), and CThreadPool_Controller::SetThreadsCount(). |
|
|
Get priority of the task.
Definition at line 629 of file thread_pool.hpp. References CThreadPool_Task::m_Priority. |
|
|
Get maximum number of tasks in queue per each thread.
Definition at line 193 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_Threshold. |
|
||||||||||
|
Get the number of requests in the queue.
Definition at line 782 of file thread_pool_old.hpp. References CBlockingQueue< TRequest >::m_Mutex, CBlockingQueue< TRequest >::m_Queue, and size. Referenced by CPoolOfThreads< CRef< CStdRequest > >::GetQueueSize(). |
|
|
Get status of the task.
Definition at line 617 of file thread_pool.hpp. References CThreadPool_Task::m_Status. Referenced by CPrefetchRequest::GetState(), CPrefetchRequest::SetProgress(), and CThreadPool_Task::x_RequestToCancel(). |
|
|
Get maximum time that task can wait in queue for processing until new thread will be launched.
Definition at line 205 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_IntegrCoeff. |
|
||||||||||
|
Check whether a new request could be immediately processed.
Definition at line 1017 of file thread_pool_old.hpp. References CBlockingQueue< TRequest >::IsFull(), and CPoolOfThreads< TRequest >::m_Queue. Referenced by CPoolOfThreads< TRequest >::WaitForRoom(), and CPoolOfThreads< TRequest >::x_AcceptRequest(). |
|
|
Check if cancelation of the task was requested.
Definition at line 611 of file thread_pool.hpp. References CThreadPool_Task::m_CancelRequested. Referenced by CPrefetchManager::IsActive(). |
|
|
Check if task execution has been already finished (successfully or not).
Definition at line 623 of file thread_pool.hpp. References CThreadPool_Task::eCompleted, and CThreadPool_Task::m_Status. Referenced by CThreadPool_Impl::CancelTask(), CPrefetchRequest::IsDone(), CThreadPool_Task::RequestToCancel(), and CThreadPool_Task::x_SetStatus(). |
|
||||||||||
|
Derived (user-created) class must provide a real thread function.
Implements CThread. Definition at line 883 of file thread_pool_old.hpp. References CAtomicCounter::Add(), ERR_POST_XX, CThreadInPool< TRequest >::eRunOnce, CThreadInPool< TRequest >::Init(), CPoolOfThreads< TRequest >::m_Delta, CThreadInPool< TRequest >::m_Pool, CPoolOfThreads< TRequest >::m_Queue, CThreadInPool< TRequest >::m_RunMode, CThreadInPool< TRequest >::ProcessRequest(), CPoolOfThreads< TRequest >::Register(), CPoolOfThreads< TRequest >::UnRegister(), and CException::what(). |
|
||||||||||
|
Override this to execute finalization code. Unlike destructor, this code will be executed before thread termination and as a part of the thread. Reimplemented from CThread. Definition at line 932 of file thread_pool_old.hpp. References CAtomicCounter::Add(), CThreadInPool< TRequest >::eRunOnce, CThreadInPool< TRequest >::m_Pool, CThreadInPool< TRequest >::m_RunMode, CPoolOfThreads< TRequest >::m_ThreadCount, CPoolOfThreads< TRequest >::m_UrgentThreadCount, STD_CATCH_ALL_XX, and CThreadInPool< TRequest >::x_OnExit(). |
|
||||||||||
|
Process a request. It is called from Main() for each request this thread handles
Definition at line 944 of file thread_pool_old.hpp. Referenced by CThreadInPool< TRequest >::Main(). |
|
||||||||||||||||||||||||
|
Put a request into the queue. If the queue remains full for the duration of the (optional) timeout, throw an exception.
Definition at line 657 of file thread_pool_old.hpp. References set< Key, Compare >::empty(), CBlockingQueue< TRequest >::m_GetSem, CBlockingQueue< TRequest >::m_Mutex, CBlockingQueue< TRequest >::m_PutSem, CBlockingQueue< TRequest >::m_Queue, NCBI_THROW, CSemaphore::Post(), CSemaphore::TryWait(), CBlockingQueue< TRequest >::x_PutSemPred(), and CBlockingQueue< TRequest >::x_WaitForPredicate(). Referenced by CPrefetchThreadOld::AddRequest(), CPrefetchThreadOld::Terminate(), and CPoolOfThreads< TRequest >::x_AcceptRequest(). |
|
|
Set the time period (in seconds) for which average speed of changing of waiting tasks number is calculated. Average speed is calculated by simple division of changing in waiting tasks number during this time period per time period value (all counts of tasks are calculated per each thread). By default parameter is set to 0.3. Definition at line 211 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_DerivTime. |
|
|
Set period of prediction of number of tasks in queue The meaning of parameter is only approximate. In fact it is the coefficient in derivative part of the algorithm. Meaning of the coefficient is like this: take average speed of changing of tasks count, multiply it by this prediction time, if the resulting value is greater than threshold then new thread is needed. By default parameter is set to 0.5.
Definition at line 223 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_DerivCoeff. |
|
|
Set maximum number of tasks in queue per each thread The meaning of parameter is only approximate. In fact it is the coefficient in proportional part of the algorithm and adjustment for all other coefficients. By default parameter is set to 3. Definition at line 187 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_Threshold. |
|
|
Set maximum time (in seconds) that task can wait in queue for processing until new thread will be launched. The meaning of parameter is only approximate. In fact it is the coefficient in integral part of the algorithm and effectively if only one task will be considered then coefficient will be multiplied by number of currently running threads and currently set threshold. By default parameter is set to 0.2.
Definition at line 199 of file thread_pool_ctrl.hpp. References CThreadPool_Controller_PID::m_IntegrCoeff. |
|
||||||||||||||||
|
Adjust a pending request's priority.
Definition at line 1103 of file thread_pool_old.hpp. |
|
||||||||||||||||
|
Adjust a pending request's priority.
Definition at line 790 of file thread_pool_old.hpp. References CQueueItemBase::ePending. |
|
||||||||||
|
Start processing threads.
Definition at line 984 of file thread_pool_old.hpp. References CAtomicCounter::Add(), CThreadInPool< TRequest >::eNormal, CPoolOfThreads< TRequest >::m_ThreadCount, CPoolOfThreads< TRequest >::NewThread(), and CThread::Run(). Referenced by CThreadedServer::Run(). |
|
||||||||||||||||
|
Wait for the queue to have waiting readers, for up to timeout_sec + timeout_nsec/1E9 seconds.
Definition at line 712 of file thread_pool_old.hpp. References CBlockingQueue< TRequest >::m_HungerSem, CBlockingQueue< TRequest >::m_Mutex, NCBI_THROW, CSemaphore::Post(), CBlockingQueue< TRequest >::x_HungerSemPred(), and CBlockingQueue< TRequest >::x_WaitForPredicate(). Referenced by CPoolOfThreads< TRequest >::WaitForRoom(). |
|
||||||||||||||||
|
Wait for the room in the queue up to timeout_sec + timeout_nsec/1E9 seconds.
Definition at line 1045 of file thread_pool_old.hpp. References CPoolOfThreads< TRequest >::HasImmediateRoom(), CPoolOfThreads< TRequest >::m_Queue, CPoolOfThreads< TRequest >::m_QueuingForbidden, CBlockingQueue< TRequest >::WaitForHunger(), and CBlockingQueue< TRequest >::WaitForRoom(). Referenced by CThreadedServer::Run(). |
|
||||||||||||||||
|
Wait for room in the queue for up to timeout_sec + timeout_nsec/1E9 seconds.
Definition at line 697 of file thread_pool_old.hpp. References CBlockingQueue< TRequest >::m_Mutex, CBlockingQueue< TRequest >::m_PutSem, NCBI_THROW, CSemaphore::Post(), CBlockingQueue< TRequest >::x_PutSemPred(), and CBlockingQueue< TRequest >::x_WaitForPredicate(). Referenced by CPoolOfThreads< TRequest >::WaitForRoom(). |
|
||||||||||
|
Withdraw a pending request from consideration.
Definition at line 813 of file thread_pool_old.hpp. References CQueueItemBase::ePending. Referenced by CPoolOfThreads< CRef< CStdRequest > >::Withdraw(). |
|
||||||||||||||||||||||||||||
|
||||||||||
|
Definition at line 245 of file thread_pool_old.hpp. References CQueueItemBase::x_SetStatus(). |
|
||||||||||||||||||||||||||||
|
||||||||||
|
Destructor.
Definition at line 973 of file thread_pool_old.hpp. References ERR_POST_XX, CAtomicCounter::Get(), CPoolOfThreads< TRequest >::m_ThreadCount, and CPoolOfThreads< TRequest >::m_UrgentThreadCount. |
1.4.6
Modified on Wed Dec 09 08:20:18 2009 by modify_doxy.py rev. 173732