OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
WWorkerThread< Function_T > Class Template Reference

A worker thread that belongs to a. More...

#include <WWorkerThread.h>

+ Inheritance diagram for WWorkerThread< Function_T >:

List of all members.

Public Types

typedef boost::function< void() > StopFunction
 a type for stop callbacks
typedef boost::function< void(WException
const &) > 
ExceptionFunction
 a type for exception callbacks

Public Member Functions

 WWorkerThread (boost::shared_ptr< Function_T > func, std::size_t id, std::size_t numThreads)
 Default constructor.
virtual ~WWorkerThread ()
 Default destructor.
void subscribeExceptionSignal (ExceptionFunction func)
 Subscribe a function to the exception signal.
void subscribeStopSignal (StopFunction func)
 Subscribe a function to the stop signal.

Protected Member Functions

virtual void threadMain ()
 The thread's main function.

Private Types

typedef
boost::signals2::signal< void() > 
StopSignal
 a type for stop signals
typedef
boost::signals2::signal< void(WException
const &) > 
ExceptionSignal
 a type for exception signals

Private Member Functions

 WWorkerThread (WWorkerThread const &)
 WWorkerThread is non-copyable, so the copy constructor is not implemented.
WWorkerThreadoperator= (WWorkerThread const &)
 WWorkerThread is non-copyable, so the copy operator is not implemented.

Private Attributes

boost::shared_ptr< Function_T > m_func
 the functor called in threadMain()
std::size_t m_id
 a thread id between 0 and m_numThreads - 1
std::size_t m_numThreads
 the number of threads
ExceptionSignal m_exceptionSignal
 the exception signal
StopSignal m_stopSignal
 the stop signal

Detailed Description

template<class Function_T>
class WWorkerThread< Function_T >

A worker thread that belongs to a.

See also:
WThreadedFunction object.

Definition at line 42 of file WWorkerThread.h.


Member Typedef Documentation

template<class Function_T>
typedef boost::function< void ( WException const& ) > WWorkerThread< Function_T >::ExceptionFunction

a type for exception callbacks

Definition at line 57 of file WWorkerThread.h.

template<class Function_T>
typedef boost::signals2::signal< void ( WException const& ) > WWorkerThread< Function_T >::ExceptionSignal [private]

a type for exception signals

Definition at line 49 of file WWorkerThread.h.

template<class Function_T>
typedef boost::function< void () > WWorkerThread< Function_T >::StopFunction

a type for stop callbacks

Definition at line 54 of file WWorkerThread.h.

template<class Function_T>
typedef boost::signals2::signal< void () > WWorkerThread< Function_T >::StopSignal [private]

a type for stop signals

Definition at line 46 of file WWorkerThread.h.


Constructor & Destructor Documentation

template<class Function_T >
WWorkerThread< Function_T >::WWorkerThread ( boost::shared_ptr< Function_T >  func,
std::size_t  id,
std::size_t  numThreads 
)

Default constructor.

Parameters:
funcA pointer to the function object.
idA thread id.
numThreadsThe number of threads.

Definition at line 123 of file WWorkerThread.h.

References WWorkerThread< Function_T >::m_func.

template<class Function_T >
WWorkerThread< Function_T >::~WWorkerThread ( ) [virtual]

Default destructor.

Definition at line 141 of file WWorkerThread.h.

template<class Function_T>
WWorkerThread< Function_T >::WWorkerThread ( WWorkerThread< Function_T > const &  ) [private]

WWorkerThread is non-copyable, so the copy constructor is not implemented.


Member Function Documentation

template<class Function_T>
WWorkerThread& WWorkerThread< Function_T >::operator= ( WWorkerThread< Function_T > const &  ) [private]

WWorkerThread is non-copyable, so the copy operator is not implemented.

Returns:
this worker-thread.
template<class Function_T >
void WWorkerThread< Function_T >::subscribeExceptionSignal ( ExceptionFunction  func)

Subscribe a function to the exception signal.

Parameters:
funcThe function.

Definition at line 148 of file WWorkerThread.h.

Referenced by WWorkerThreadTest::testExceptions().

template<class Function_T >
void WWorkerThread< Function_T >::subscribeStopSignal ( StopFunction  func)

Subscribe a function to the stop signal.

Parameters:
funcThe function.

Definition at line 157 of file WWorkerThread.h.

Referenced by WWorkerThreadTest::testSingleThread(), and WWorkerThreadTest::testStopThread().

template<class Function_T >
void WWorkerThread< Function_T >::threadMain ( ) [protected, virtual]

The thread's main function.

Reimplemented from WThreadedRunner.

Definition at line 166 of file WWorkerThread.h.


Member Data Documentation

template<class Function_T>
ExceptionSignal WWorkerThread< Function_T >::m_exceptionSignal [private]

the exception signal

Definition at line 116 of file WWorkerThread.h.

template<class Function_T>
boost::shared_ptr< Function_T > WWorkerThread< Function_T >::m_func [private]

the functor called in threadMain()

Definition at line 107 of file WWorkerThread.h.

Referenced by WWorkerThread< Function_T >::WWorkerThread().

template<class Function_T>
std::size_t WWorkerThread< Function_T >::m_id [private]

a thread id between 0 and m_numThreads - 1

Definition at line 110 of file WWorkerThread.h.

template<class Function_T>
std::size_t WWorkerThread< Function_T >::m_numThreads [private]

the number of threads

Definition at line 113 of file WWorkerThread.h.

template<class Function_T>
StopSignal WWorkerThread< Function_T >::m_stopSignal [private]

the stop signal

Definition at line 119 of file WWorkerThread.h.


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