OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
WThreadedFunctionBase Class Referenceabstract

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

#include <WThreadedFunction.h>

+ Inheritance diagram for WThreadedFunctionBase:
+ Collaboration diagram for WThreadedFunctionBase:

Public Types

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Private Types

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

Detailed Description

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

Definition at line 65 of file WThreadedFunction.h.

Member Typedef Documentation

◆ ExceptionFunction

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

a type for exception callbacks

Definition at line 72 of file WThreadedFunction.h.

◆ ExceptionSignal

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

a type for exception signals

Definition at line 68 of file WThreadedFunction.h.

Constructor & Destructor Documentation

◆ WThreadedFunctionBase() [1/2]

WThreadedFunctionBase::WThreadedFunctionBase ( )

Standard constructor.

Definition at line 29 of file WThreadedFunction.cpp.

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

+ Here is the call graph for this function:

◆ ~WThreadedFunctionBase()

WThreadedFunctionBase::~WThreadedFunctionBase ( )
virtual

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

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

Definition at line 38 of file WThreadedFunction.cpp.

References m_exceptionSignal.

◆ WThreadedFunctionBase() [2/2]

WThreadedFunctionBase::WThreadedFunctionBase ( WThreadedFunctionBase const &  )
protected

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

Member Function Documentation

◆ getThreadsDoneCondition()

std::shared_ptr< WCondition > WThreadedFunctionBase::getThreadsDoneCondition ( )

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

Returns
The condition indicating all threads are done.

Definition at line 48 of file WThreadedFunction.cpp.

References m_doneCondition.

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

+ Here is the caller graph for this function:

◆ operator=()

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

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

Returns
this function

◆ run()

virtual void WThreadedFunctionBase::run ( )
pure virtual

Starts the threads.

Implemented in WThreadedFunction< Function_T >.

◆ status()

WThreadedFunctionStatus WThreadedFunctionBase::status ( )

Get the status of the threads.

Returns
The current status.

Definition at line 43 of file WThreadedFunction.cpp.

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

Referenced by WThreadedFunctionTest::testExceptionHandling(), WThreadedFunctionTest::testMultipleThreads(), WThreadedFunctionTest::testStopCondition(), and WThreadedFunctionTest::testStopThreads().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

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 >.

◆ subscribeExceptionSignal()

void WThreadedFunctionBase::subscribeExceptionSignal ( ExceptionFunction  func)

Subscribe a function to an exception signal.

Parameters
funcThe function to subscribe.

Definition at line 53 of file WThreadedFunction.cpp.

References m_exceptionSignal.

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

+ Here is the caller graph for this function:

◆ wait()

virtual void WThreadedFunctionBase::wait ( )
pure virtual

Wait for all threads to stop.

Implemented in WThreadedFunction< Function_T >.

Member Data Documentation

◆ m_doneCondition

std::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().

◆ m_exceptionSignal

ExceptionSignal WThreadedFunctionBase::m_exceptionSignal
protected

a signal for exceptions

Definition at line 140 of file WThreadedFunction.h.

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

◆ m_status

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: