A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/classCThreadPool__Impl.html below:

NCBI C++ ToolKit: CThreadPool_Impl Class Reference

Search Toolkit Book for CThreadPool_Impl

Real implementation of all ThreadPool functions. More...

  CThreadPool_Impl (CThreadPool *pool_intf, unsigned int queue_size, unsigned int max_threads, unsigned int min_threads, CThread::TRunMode threads_mode=CThread::fRunDefault)   Constructor with default controller. More...
    CThreadPool_Impl (CThreadPool *pool_intf, unsigned int queue_size, CThreadPool_Controller *controller, CThread::TRunMode threads_mode=CThread::fRunDefault)   Constructor with explicitly given controller. More...
  CThreadPoolGetPoolInterface (void) const   Get pointer to ThreadPool interface object. More...
  void  SetDestroyTimeout (const CTimeSpan &timeout)   Set destroy timeout for the pool. More...
  const CTimeSpanGetDestroyTimeout (void) const   Get destroy timeout for the pool. More...
  void  DestroyReference (void)   Destroy reference to this object Method is called when CThreadPool object is destroyed which means that implementation can be destroyed too if there is no references to it left. More...
  CMutexGetMainPoolMutex (void)   Get main pool mutex. More...
  void  AddTask (CThreadPool_Task *task, const CTimeSpan *timeout)   Add task to the pool. More...
  void  CancelTask (CThreadPool_Task *task)   Request to cancel the task. More...
  void  CancelTasks (TExclusiveFlags tasks_group)   Cancel the selected groups of tasks in the pool. More...
  void  RequestExclusiveExecution (CThreadPool_Task *task, TExclusiveFlags flags)   Add the task for exclusive execution in the pool. More...
  void  LaunchThreads (unsigned int count)   Launch new threads in pool. More...
  void  FinishThreads (unsigned int count)   Finish threads in pool Stop first all idle threads then stop busy threads without cancelation of currently executing tasks. More...
  unsigned int  GetThreadsCount (void) const   Get number of threads running in the pool. More...
  bool  SetThreadIdle (CThreadPool_ThreadImpl *thread, bool is_idle)   Mark thread as idle or non-idle. More...
  void  ThreadStopped (CThreadPool_ThreadImpl *thread)   Callback from working thread when it finished its Main() method. More...
  void  ThreadStateChanged (void)   Callback when some thread changed its idleness or finished (including service thread) More...
  CRef< CThreadPool_TaskTryGetNextTask (void)   Get next task from queue if there is one If the queue is empty then return NULL. More...
  void  TaskStarting (void)   Callback from thread when it is starting to execute task. More...
  void  TaskFinished (void)   Callback from thread when it has finished to execute task. More...
  unsigned int  GetQueuedTasksCount (void) const   Get the number of tasks currently waiting in queue. More...
  unsigned int  GetExecutingTasksCount (void) const   Get the number of currently executing tasks. More...
  SExclusiveTaskInfo  TryGetExclusiveTask (void)   Get the next exclusive task to execute. More...
  void  RequestSuspend (TExclusiveFlags flags)   Request suspension of the pool. More...
  void  ResumeWork (void)   Resume the pool operation after exclusive task execution. More...
  bool  IsSuspended (void) const   Check if the pool is suspended for exclusive execution. More...
  bool  CanDoExclusiveTask (void) const   Check if it is already allowed to execute exclusive task. More...
  void  Abort (const CTimeSpan *timeout)   Abort the pool operation. More...
  bool  IsAborted (void) const   Check if the pool is already aborted. More...
  void  FlushThreads (CThreadPool::EFlushType flush_type)   Finish all current threads and replace them with new ones. More...
  void  CallController (CThreadPool_Controller::EEvent event)   Call the CThreadPool_Controller::HandleEvent() method of the pool controller with the given event type. More...
  void  CallControllerOther (void)   Schedule running of CThreadPool_Controller::HandleEvent() with eOther event type. More...
  CTimeSpan  GetSafeSleepTime (void) const   Call the CThreadPool_Controller::GetSafeSleepTime() method of the pool controller. More...
  void  SetInterfaceStarted (void)   Mark that initialization of the interface was finished. More...
    CObject (void)   Constructor. More...
    CObject (const CObject &src)   Copy constructor. More...
  virtual  ~CObject (void)   Destructor. More...
  CObjectoperator= (const CObject &src) THROWS_NONE   Assignment operator. More...
  bool  CanBeDeleted (void) const THROWS_NONE   Check if object can be deleted. More...
  bool  IsAllocatedInPool (void) const THROWS_NONE   Check if object is allocated in memory pool (not system heap) More...
  bool  Referenced (void) const THROWS_NONE   Check if object is referenced. More...
  bool  ReferencedOnlyOnce (void) const THROWS_NONE   Check if object is referenced only once. More...
  void  AddReference (void) const   Add reference to object. More...
  void  RemoveReference (void) const   Remove reference to object. More...
  void  ReleaseReference (void) const   Remove reference without deleting object. More...
  virtual void  DoNotDeleteThisObject (void)   Mark this object as not allocated in heap – do not delete this object. More...
  virtual void  DoDeleteThisObject (void)   Mark this object as allocated in heap – object can be deleted. More...
  void *  operator new (size_t size)   Define new operator for memory allocation. More...
  void *  operator new[] (size_t size)   Define new[] operator for 'array' memory allocation. More...
  void  operator delete (void *ptr)   Define delete operator for memory deallocation. More...
  void  operator delete[] (void *ptr)   Define delete[] operator for memory deallocation. More...
  void *  operator new (size_t size, void *place)   Define new operator. More...
  void  operator delete (void *ptr, void *place)   Define delete operator. More...
  void *  operator new (size_t size, CObjectMemoryPool *place)   Define new operator using memory pool. More...
  void  operator delete (void *ptr, CObjectMemoryPool *place)   Define delete operator. More...
  virtual void  DebugDump (CDebugDumpContext ddc, unsigned int depth) const   Define method for dumping debug information. More...
    CDebugDumpable (void)   virtual  ~CDebugDumpable (void)   void  DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const   void  DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const   void  DumpToConsole (void) const  

Real implementation of all ThreadPool functions.

Definition at line 58 of file thread_pool.cpp.

◆ TExclusiveFlags ◆ TExclusiveQueue

Type of queue used for storing information about exclusive tasks.

Definition at line 258 of file thread_pool.cpp.

◆ TQueue ◆ TThreadsList ◆ TWaitPredicate typedef bool(CThreadPool_Impl::* CThreadPool_Impl::TWaitPredicate) (void) const private ◆ CThreadPool_Impl() [1/3] ◆ CThreadPool_Impl() [2/3] ◆ CThreadPool_Impl() [3/3]

Prohibit copying and assigning.

◆ ~CThreadPool_Impl() CThreadPool_Impl::~CThreadPool_Impl ( void  ) private ◆ Abort()

Abort the pool operation.

See also
CThreadPool::Abort()

Definition at line 1916 of file thread_pool.cpp.

References CTimeSpan::AsSmartString(), CSyncQueue_AccessGuard< Type, Container, Traits >::Begin(), CSyncQueue< Type, Container, Traits >::Clear(), Critical(), CSyncQueue_AccessGuard< Type, Container, Traits >::End(), ERR_POST_X, CStopWatch::eStart, FinishThreads(), GetQueuedTasksCount(), CSyncQueue< Type, Container, Traits >::GetSize(), GetThreadsCount(), m_Aborted, m_AbortWait, m_Controller, m_ExclusiveQueue, m_ServiceThread, CRef< C, Locker >::NotNull(), CSemaphore::Post(), CThreadPool_ServiceThread::RequestToFinish(), Warning(), x_CancelExecutingTasks(), x_CancelQueuedTasks(), CThreadPool_Controller::x_DetachFromPool(), x_HasNoThreads(), and x_WaitForPredicate().

Referenced by CThreadPool::Abort(), and DestroyReference().

◆ AddTask()

Add task to the pool.

See also
CThreadPool::AddTask()

Definition at line 1669 of file thread_pool.cpp.

References _ASSERT, CAtomicCounter::Add(), CallControllerOther(), check_flags(), count, CThreadPool_Task::eIdle, CStopWatch::Elapsed(), CThreadPool_Task::eQueued, CStopWatch::eStart, CThreadPool::fCancelQueuedTasks, CThreadPool::fDoNotAllowNewTasks, CTimeSpan::GetAsDouble(), GetQueuedTasksCount(), CSyncQueue< Type, Container, Traits >::GetSize(), GetThreadsCount(), CThreadPool_Guard::Guard(), int, IsSuspended(), ITERATE, LaunchThreads(), m_Aborted, m_IdleThreads, m_IsQueueAllowed, m_Queue, m_RoomWait, m_SuspendFlags, m_TotalTasks, NCBI_THROW, CSyncQueue< Type, Container, Traits >::Push(), Ref(), ThrowAddProhibited(), x_CanAddImmediateTask(), x_CancelQueuedTasks(), x_NoNewTaskAllowed(), CThreadPool_Task::x_ResetOwner(), CThreadPool_Task::x_SetOwner(), CThreadPool_Task::x_SetStatus(), and x_WaitForPredicate().

Referenced by CThreadPool::AddTask().

◆ CallController() ◆ CallControllerOther() void CThreadPool_Impl::CallControllerOther ( void  ) inline ◆ CancelTask()

Request to cancel the task.

See also
CThreadPool::CancelTask()

Definition at line 1799 of file thread_pool.cpp.

References _ASSERT, CallControllerOther(), CThreadPool_Task::eIdle, CThreadPool_Task::GetPool(), CThreadPool_Task::GetStatus(), CThreadPool_Task::IsFinished(), m_Interface, NCBI_THROW, x_RemoveTaskFromQueue(), and CThreadPool_Task::x_RequestToCancel().

Referenced by CThreadPool::CancelTask(), and CThreadPool_Task::RequestToCancel().

◆ CancelTasks() ◆ CanDoExclusiveTask() bool CThreadPool_Impl::CanDoExclusiveTask ( void  ) const inline ◆ DestroyReference() void CThreadPool_Impl::DestroyReference ( void  ) inline ◆ FinishThreads() void CThreadPool_Impl::FinishThreads ( unsigned int  count ) ◆ FlushThreads()

Finish all current threads and replace them with new ones.

See also
CThreadPool::FlushThreads()

Definition at line 1880 of file thread_pool.cpp.

References CThreadPool::eStartImmediately, CThreadPool::eWaitToFinish, CThreadPool::fFlushThreads, FinishThreads(), CSyncQueue< Type, Container, Traits >::GetSize(), GetThreadsCount(), IsSuspended(), m_Aborted, m_ExclusiveQueue, m_FlushRequested, NCBI_THROW, and RequestExclusiveExecution().

Referenced by CThreadPool::FlushThreads().

◆ GetDestroyTimeout() ◆ GetExecutingTasksCount() unsigned int CThreadPool_Impl::GetExecutingTasksCount ( void  ) const inline ◆ GetMainPoolMutex() CMutex & CThreadPool_Impl::GetMainPoolMutex ( void  ) inline ◆ GetPoolInterface() CThreadPool * CThreadPool_Impl::GetPoolInterface ( void  ) const inline ◆ GetQueuedTasksCount() unsigned int CThreadPool_Impl::GetQueuedTasksCount ( void  ) const inline ◆ GetSafeSleepTime() CTimeSpan CThreadPool_Impl::GetSafeSleepTime ( void  ) const inline ◆ GetThreadsCount() unsigned int CThreadPool_Impl::GetThreadsCount ( void  ) const inline ◆ IsAborted() bool CThreadPool_Impl::IsAborted ( void  ) const inline ◆ IsSuspended() bool CThreadPool_Impl::IsSuspended ( void  ) const inline ◆ LaunchThreads() void CThreadPool_Impl::LaunchThreads ( unsigned int  count )

Launch new threads in pool.

Parameters
count Number of threads to launch

Definition at line 1499 of file thread_pool.cpp.

References CAtomicCounter::Add(), CallControllerOther(), count, CThreadPool::CreateThread(), i, set< Key, Compare >::insert(), m_IdleThreads, m_Interface, m_ThreadsCount, m_ThreadsMode, and CThreadPool_ThreadImpl::s_GetImplPointer().

Referenced by AddTask(), CThreadPool_Controller::EnsureLimits(), and CThreadPool_Controller::SetThreadsCount().

◆ operator=() ◆ RequestExclusiveExecution()

Add the task for exclusive execution in the pool.

See also
CThreadPool::RequestExclusiveExecution()

Definition at line 1774 of file thread_pool.cpp.

References _ASSERT, CThreadPool_Task::eQueued, flags, m_Aborted, m_ExclusiveQueue, m_ServiceThread, NCBI_THROW, CSyncQueue< Type, Container, Traits >::Push(), Ref(), CThreadPool_ServiceThread::WakeUp(), CThreadPool_Task::x_SetOwner(), and CThreadPool_Task::x_SetStatus().

Referenced by FlushThreads(), and CThreadPool::RequestExclusiveExecution().

◆ RequestSuspend()

Request suspension of the pool.

Parameters
flags Parameters for necessary exclusive execution environment

Definition at line 890 of file thread_pool.cpp.

References CallController(), CThreadPool_Controller::eSuspend, CThreadPool::fCancelExecutingTasks, CThreadPool::fCancelQueuedTasks, CThreadPool::fFlushThreads, FinishThreads(), flags, m_IdleThreads, m_Suspended, m_SuspendFlags, set< Key, Compare >::size(), x_CancelExecutingTasks(), and x_CancelQueuedTasks().

Referenced by CThreadPool_ServiceThread::Main().

◆ ResumeWork() void CThreadPool_Impl::ResumeWork ( void  ) inline ◆ s_GetImplPointer() ◆ SetDestroyTimeout() void CThreadPool_Impl::SetDestroyTimeout ( const CTimeSpantimeout ) inline ◆ SetInterfaceStarted() void CThreadPool_Impl::SetInterfaceStarted ( void  ) inline ◆ SetThreadIdle()

Mark thread as idle or non-idle.

Parameters
thread Thread to mark is_idle If thread should be marked as idle or not

Definition at line 1555 of file thread_pool.cpp.

References set< Key, Compare >::end(), set< Key, Compare >::erase(), CThreadPool::fFlushThreads, set< Key, Compare >::find(), CSyncQueue< Type, Container, Traits >::GetSize(), set< Key, Compare >::insert(), IsSuspended(), m_IdleThreads, m_Queue, m_SuspendFlags, m_WorkingThreads, CThreadPool_ThreadImpl::RequestToFinish(), ThreadStateChanged(), and CThreadPool_ThreadImpl::WakeUp().

Referenced by CThreadPool_ThreadImpl::x_SetIdleState().

◆ sx_RequestToCancel() ◆ sx_SetTaskStatus() ◆ TaskFinished() void CThreadPool_Impl::TaskFinished ( void  ) inline ◆ TaskStarting() void CThreadPool_Impl::TaskStarting ( void  ) inline ◆ ThreadStateChanged() void CThreadPool_Impl::ThreadStateChanged ( void  ) inline

Callback when some thread changed its idleness or finished (including service thread)

Definition at line 798 of file thread_pool.cpp.

References CThreadPool::fFlushThreads, GetThreadsCount(), IsSuspended(), m_Aborted, m_AbortWait, m_ServiceThread, m_SuspendFlags, m_WorkingThreads, CSemaphore::Post(), set< Key, Compare >::size(), CThreadPool_ServiceThread::WakeUp(), and x_HasNoThreads().

Referenced by CThreadPool_ServiceThread::Main(), SetThreadIdle(), and ThreadStopped().

◆ ThreadStopped() ◆ TryGetExclusiveTask()

Get the next exclusive task to execute.

Definition at line 857 of file thread_pool.cpp.

References CSyncQueue_AccessGuard< Type, Container, Traits >::Begin(), CThreadPool::fExecuteQueuedTasks, CThreadPool::fFlushThreads, CAtomicCounter::Get(), CSyncQueue< Type, Container, Traits >::GetSize(), info, m_ExclusiveQueue, m_FlushRequested, m_TotalTasks, and CSyncQueue< Type, Container, Traits >::Pop().

Referenced by CThreadPool_ServiceThread::Main().

◆ TryGetNextTask() ◆ x_CanAddImmediateTask() bool CThreadPool_Impl::x_CanAddImmediateTask ( void  ) const private ◆ x_CancelExecutingTasks() void CThreadPool_Impl::x_CancelExecutingTasks ( void  ) private ◆ x_CancelQueuedTasks() void CThreadPool_Impl::x_CancelQueuedTasks ( void  ) private

Cancel all tasks waiting in the queue.

Definition at line 1866 of file thread_pool.cpp.

References CSyncQueue_AccessGuard< Type, Container, Traits >::Begin(), CSyncQueue< Type, Container, Traits >::Clear(), CSyncQueue_AccessGuard< Type, Container, Traits >::End(), and m_Queue.

Referenced by Abort(), AddTask(), CancelTasks(), and RequestSuspend().

◆ x_GetQueueSize() unsigned int CThreadPool_Impl::x_GetQueueSize ( unsigned int  queue_size ) inlineprivate

Transform size of queue given in constructor to the size passed to CSyncQueue constructor.

Method can be called only from constructor because it initializes value of m_IsQueueAllowed member variable.

Definition at line 1403 of file thread_pool.cpp.

References m_IsQueueAllowed.

◆ x_HasNoThreads() bool CThreadPool_Impl::x_HasNoThreads ( void  ) const private ◆ x_Init()

Initialization of all class member variables that can be initialized outside of constructor.

Parameters
pool_intf ThreadPool interface object attached to this implementation controller Controller for the pool

Definition at line 1446 of file thread_pool.cpp.

References CThread::fRunAllowST, CThread::fRunDetached, m_Aborted, m_Controller, m_DestroyTimeout, m_ExecutingTasks, m_FlushRequested, m_Interface, m_SelfRef, m_ServiceThread, m_Suspended, m_ThreadsCount, m_ThreadsMode, m_TotalTasks, CAtomicCounter::Set(), and CThreadPool_Controller::x_AttachToPool().

Referenced by CThreadPool_Impl().

◆ x_NoNewTaskAllowed() bool CThreadPool_Impl::x_NoNewTaskAllowed ( void  ) const inlineprivate ◆ x_RemoveTaskFromQueue() ◆ x_WaitForPredicate() ◆ m_Aborted atomic<bool> CThreadPool_Impl::m_Aborted private ◆ m_AbortWait ◆ m_Controller ◆ m_DestroyTimeout ◆ m_ExclusiveQueue ◆ m_ExecutingTasks ◆ m_FlushRequested volatile bool CThreadPool_Impl::m_FlushRequested private ◆ m_IdleThreads ◆ m_Interface ◆ m_IsQueueAllowed bool CThreadPool_Impl::m_IsQueueAllowed private ◆ m_MainPoolMutex CMutex CThreadPool_Impl::m_MainPoolMutex private ◆ m_Queue TQueue CThreadPool_Impl::m_Queue private ◆ m_RoomWait ◆ m_SelfRef ◆ m_ServiceThread ◆ m_Suspended atomic<bool> CThreadPool_Impl::m_Suspended private

If pool is suspended for exclusive task execution or not.

Thread Checker can complain that access to this variable everywhere is not guarded by some mutex. But it's okay because special care is taken to make any race a matter of timing - suspend will happen properly in any case. Also everything is written with the assumption that there's no other threads (besides this very thread pool) that could call any methods here.

Definition at line 382 of file thread_pool.cpp.

Referenced by IsSuspended(), RequestSuspend(), ResumeWork(), and x_Init().

◆ m_SuspendFlags ◆ m_ThreadsCount ◆ m_ThreadsMode ◆ m_TotalTasks ◆ m_WorkingThreads

The documentation for this class was generated from the following file:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4