NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
CStdPoolOfThreads Class Reference

Search Toolkit Book for CStdPoolOfThreads

#include <util/thread_pool_old.hpp>

+ Inheritance diagram for CStdPoolOfThreads:
+ Collaboration diagram for CStdPoolOfThreads:

Public Types

enum  EKillFlags { fKill_Wait = 0x1 , fKill_Reopen = 0x2 }
 
typedef CPoolOfThreads< CRef< CStdRequest > > TParent
 
typedef int TKillFlags
 binary OR of EKillFlags More...
 
- Public Types inherited from CPoolOfThreads< CRef< CStdRequest > >
typedef CThreadInPool< CRef< CStdRequest > > TThread
 
typedef TThread::ERunMode ERunMode
 
typedef CBlockingQueue< CRef< CStdRequest > > TQueue
 
typedef TQueue::TUserPriority TUserPriority
 
typedef TQueue::TItemHandle TItemHandle
 

Public Member Functions

 CStdPoolOfThreads (unsigned int max_threads, unsigned int queue_size, unsigned int spawn_threshold=1, unsigned int max_urgent_threads=kMax_UInt, const string &thread_name=kEmptyStr)
 Constructor. More...
 
virtual ~CStdPoolOfThreads ()
 
virtual void KillAllThreads (TKillFlags flags)
 Causes all threads in the pool to exit cleanly after finishing all pending requests, optionally waiting for them to die. More...
 
virtual void KillAllThreads (bool wait)
 Causes all threads in the pool to exit cleanly after finishing all pending requests, optionally waiting for them to die. More...
 
virtual void Register (TThread &thread)
 Register a thread. More...
 
virtual void UnRegister (TThread &thread)
 Unregister a thread. More...
 
- Public Member Functions inherited from CPoolOfThreads< CRef< CStdRequest > >
 CPoolOfThreads (unsigned int max_threads, unsigned int queue_size, unsigned int spawn_threshold=1, unsigned int max_urgent_threads=kMax_UInt, const string &thread_name=kEmptyStr)
 Constructor. More...
 
virtual ~CPoolOfThreads (void)
 Destructor. More...
 
void Spawn (unsigned int num_threads)
 Start processing threads. More...
 
TItemHandle AcceptRequest (const CRef< CStdRequest > &request, TUserPriority priority=0, unsigned int timeout_sec=0, unsigned int timeout_nsec=0)
 Put a request in the queue with a given priority. More...
 
TItemHandle AcceptUrgentRequest (const CRef< CStdRequest > &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. More...
 
void 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. More...
 
bool IsFull (void) const
 Check if the queue is full. More...
 
bool IsEmpty (void) const
 Check if the queue is empty. More...
 
bool HasImmediateRoom (bool urgent=false) const
 Check whether a new request could be immediately processed. More...
 
void SetUserPriority (TItemHandle handle, TUserPriority priority)
 Adjust a pending request's priority. More...
 
void Withdraw (TItemHandle handle)
 Withdraw a pending request from consideration. More...
 
size_t GetQueueSize (void) const
 Get the number of requests in the queue. More...
 

Protected Member Functions

virtual TThreadNewThread (TThread::ERunMode mode)
 Create a new thread. More...
 
- Protected Member Functions inherited from CPoolOfThreads< CRef< CStdRequest > >
virtual void Register (TThread &thread)
 Register a thread. More...
 
virtual void UnRegister (TThread &)
 Unregister a thread. More...
 

Private Types

typedef list< CRef< TThread > > TThreads
 

Private Attributes

TThreads m_Threads
 

Additional Inherited Members

- Protected Types inherited from CPoolOfThreads< CRef< CStdRequest > >
typedef CAtomicCounter::TValue TACValue
 
- Protected Attributes inherited from CPoolOfThreads< CRef< CStdRequest > >
CAtomicCounter_WithAutoInit m_MaxThreads
 The maximum number of threads the pool can hold. More...
 
CAtomicCounter_WithAutoInit m_MaxUrgentThreads
 The maximum number of urgent threads running simultaneously. More...
 
int m_Threshold
 for delta More...
 
CAtomicCounter_WithAutoInit m_ThreadCount
 The current number of threads in the pool. More...
 
CAtomicCounter_WithAutoInit m_UrgentThreadCount
 The current number of urgent threads running now. More...
 
atomic< intm_Delta
 The difference between the number of unfinished requests and the total number of threads in the pool. More...
 
CMutex m_Mutex
 The guard for m_MaxThreads, m_MaxUrgentThreads, and m_Delta. More...
 
TQueue m_Queue
 The request queue. More...
 
bool m_QueuingForbidden
 
const string m_ThreadName
 

Detailed Description

Definition at line 606 of file thread_pool_old.hpp.


The documentation for this class was generated from the following files:
Modified on Tue Apr 23 07:36:53 2024 by modify_doxy.py rev. 669887