The Gaudi Framework  v29r0 (ff2e7097)
boost::threadpool::detail::worker_thread< Pool > Class Template Reference

Thread pool worker. More...

#include <src/threadpool/boost/threadpool/detail/worker_thread.hpp>

Inheritance diagram for boost::threadpool::detail::worker_thread< Pool >:
Collaboration diagram for boost::threadpool::detail::worker_thread< Pool >:

Public Types

typedef Pool pool_type
 Indicates the pool's type. More...
 

Public Member Functions

void run ()
 Executes pool's tasks sequentially. More...
 
void join ()
 Joins the worker's thread. More...
 

Static Public Member Functions

static void create_and_attach (shared_ptr< pool_type > const &pool)
 Constructs a new worker thread and attaches it to the pool. More...
 

Private Member Functions

 worker_thread (shared_ptr< pool_type > const &pool)
 Constructs a new worker. More...
 
void died_unexpectedly ()
 Notifies that an exception occurred in the run loop. More...
 

Private Attributes

shared_ptr< pool_typem_pool
 Pointer to the pool which created the worker. More...
 
shared_ptr< boost::thread > m_thread
 Pointer to the thread which executes the run loop. More...
 

Detailed Description

template<typename Pool>
class boost::threadpool::detail::worker_thread< Pool >

Thread pool worker.

A worker_thread represents a thread of execution. The worker is attached to a thread pool and processes tasks of that pool. The lifetime of the worker and its internal boost::thread is managed automatically.

This class is a helper class and cannot be constructed or accessed directly.

See also
pool_core

Definition at line 44 of file worker_thread.hpp.

Member Typedef Documentation

template<typename Pool>
typedef Pool boost::threadpool::detail::worker_thread< Pool >::pool_type

Indicates the pool's type.

Definition at line 49 of file worker_thread.hpp.

Constructor & Destructor Documentation

template<typename Pool>
boost::threadpool::detail::worker_thread< Pool >::worker_thread ( shared_ptr< pool_type > const &  pool)
inlineprivate

Constructs a new worker.

Parameters
poolPointer to it's parent pool.
See also
function create_and_attach

Definition at line 60 of file worker_thread.hpp.

61  : m_pool(pool)
62  {
63  assert(pool);
64  }
shared_ptr< pool_type > m_pool
Pointer to the pool which created the worker.

Member Function Documentation

template<typename Pool>
static void boost::threadpool::detail::worker_thread< Pool >::create_and_attach ( shared_ptr< pool_type > const &  pool)
inlinestatic

Constructs a new worker thread and attaches it to the pool.

Parameters
poolPointer to the pool.

Definition at line 100 of file worker_thread.hpp.

101  {
102  shared_ptr<worker_thread> worker(new worker_thread(pool));
103  if(worker)
104  {
105  worker->m_thread.reset(new boost::thread(bind(&worker_thread::run, worker)));
106  }
107  }
worker_thread(shared_ptr< pool_type > const &pool)
Constructs a new worker.
void run()
Executes pool&#39;s tasks sequentially.
T bind(T...args)
template<typename Pool>
void boost::threadpool::detail::worker_thread< Pool >::died_unexpectedly ( )
inlineprivate

Notifies that an exception occurred in the run loop.

Definition at line 69 of file worker_thread.hpp.

70  {
71  m_pool->worker_died_unexpectedly(this->shared_from_this());
72  }
shared_ptr< pool_type > m_pool
Pointer to the pool which created the worker.
template<typename Pool>
void boost::threadpool::detail::worker_thread< Pool >::join ( )
inline

Joins the worker's thread.

Definition at line 91 of file worker_thread.hpp.

92  {
93  m_thread->join();
94  }
shared_ptr< boost::thread > m_thread
Pointer to the thread which executes the run loop.
template<typename Pool>
void boost::threadpool::detail::worker_thread< Pool >::run ( )
inline

Executes pool's tasks sequentially.

Definition at line 78 of file worker_thread.hpp.

79  {
80  scope_guard notify_exception(bind(&worker_thread::died_unexpectedly, this));
81 
82  while(m_pool->execute_task()) {}
83 
84  notify_exception.disable();
85  m_pool->worker_destructed(this->shared_from_this());
86  }
void died_unexpectedly()
Notifies that an exception occurred in the run loop.
T bind(T...args)
shared_ptr< pool_type > m_pool
Pointer to the pool which created the worker.

Member Data Documentation

template<typename Pool>
shared_ptr<pool_type> boost::threadpool::detail::worker_thread< Pool >::m_pool
private

Pointer to the pool which created the worker.

Definition at line 52 of file worker_thread.hpp.

template<typename Pool>
shared_ptr<boost::thread> boost::threadpool::detail::worker_thread< Pool >::m_thread
private

Pointer to the thread which executes the run loop.

Definition at line 53 of file worker_thread.hpp.


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