OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types
WThreadedFunctionBase Class Reference

A virtual base class for threaded functions (see below). More...

#include <WThreadedFunction.h>

+ Inheritance diagram for WThreadedFunctionBase:

List of all members.

Public Types

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

Public Member Functions

 WThreadedFunctionBase ()
 Standard constructor.
virtual ~WThreadedFunctionBase ()
 Destroys the thread pool and stops all threads, if any one of them is still running.
virtual void run ()=0
 Starts the threads.
virtual void stop ()=0
 Request all threads to stop.
virtual void wait ()=0
 Wait for all threads to stop.
WThreadedFunctionStatus status ()
 Get the status of the threads.
boost::shared_ptr< WConditiongetThreadsDoneCondition ()
 Returns a condition that gets fired when all threads have finished.
void subscribeExceptionSignal (ExceptionFunction func)
 Subscribe a function to an exception signal.

Protected Member Functions

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

Protected Attributes

boost::shared_ptr< WConditionm_doneCondition
 a condition that gets notified when the work is complete
ExceptionSignal m_exceptionSignal
 a signal for exceptions
WSharedObject
< WThreadedFunctionStatus > 
m_status
 the current status

Private Types

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

Detailed Description

A virtual base class for threaded functions (see below).

Definition at line 65 of file WThreadedFunction.h.


Member Typedef Documentation

typedef boost::function< void ( WException const& ) > WThreadedFunctionBase::ExceptionFunction

a type for exception callbacks

Reimplemented in WThreadedFunction< Function_T >.

Definition at line 72 of file WThreadedFunction.h.

typedef boost::signals2::signal< void ( WException const& ) > WThreadedFunctionBase::ExceptionSignal [private]

a type for exception signals

Reimplemented in WThreadedFunction< Function_T >.

Definition at line 68 of file WThreadedFunction.h.


Constructor & Destructor Documentation

Standard constructor.

Definition at line 27 of file WThreadedFunction.cpp.

References WSharedObject< T >::getWriteTicket(), and m_status.

Destroys the thread pool and stops all threads, if any one of them is still running.

Notes:
Of course, the client has to make sure the threads do not work endlessly on a single job.

Definition at line 36 of file WThreadedFunction.cpp.

References m_exceptionSignal.

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


Member Function Documentation

Returns a condition that gets fired when all threads have finished.

Returns:
The condition indicating all threads are done.

Definition at line 46 of file WThreadedFunction.cpp.

References m_doneCondition.

Referenced by WThreadedPerVoxelOperationTest::testMultithreadedFunction(), and WThreadedFunctionTest::testStopCondition().

WThreadedFunctionBase& WThreadedFunctionBase::operator= ( WThreadedFunctionBase const &  ) [protected]

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

Returns:
this function
virtual void WThreadedFunctionBase::run ( ) [pure virtual]

Starts the threads.

Implemented in WThreadedFunction< Function_T >.

WThreadedFunctionStatus WThreadedFunctionBase::status ( )
virtual void WThreadedFunctionBase::stop ( ) [pure virtual]

Request all threads to stop.

Returns immediately, so you might have to wait() for the threads to actually finish.

Implemented in WThreadedFunction< Function_T >.

Subscribe a function to an exception signal.

Parameters:
funcThe function to subscribe.

Definition at line 51 of file WThreadedFunction.cpp.

References m_exceptionSignal.

Referenced by WThreadedFunctionTest::testExceptionHandling(), and WThreadedPerVoxelOperationTest::testMultithreadedFunction().

virtual void WThreadedFunctionBase::wait ( ) [pure virtual]

Wait for all threads to stop.

Implemented in WThreadedFunction< Function_T >.


Member Data Documentation

boost::shared_ptr< WCondition > WThreadedFunctionBase::m_doneCondition [protected]

a condition that gets notified when the work is complete

Definition at line 137 of file WThreadedFunction.h.

Referenced by getThreadsDoneCondition().

a signal for exceptions

Definition at line 140 of file WThreadedFunction.h.

Referenced by subscribeExceptionSignal(), and ~WThreadedFunctionBase().

WSharedObject< WThreadedFunctionStatus > WThreadedFunctionBase::m_status [protected]

the current status

Definition at line 143 of file WThreadedFunction.h.

Referenced by status(), and WThreadedFunctionBase().


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