OpenWalnut
1.4.0
|
A virtual base class for threaded functions (see below). More...
#include <WThreadedFunction.h>
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< WCondition > | getThreadsDoneCondition () |
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. | |
WThreadedFunctionBase & | operator= (WThreadedFunctionBase const &) |
WThreadedFunctionBase is non-copyable, so the copy operator is not implemented. | |
Protected Attributes | |
boost::shared_ptr< WCondition > | m_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 |
A virtual base class for threaded functions (see below).
Definition at line 65 of file WThreadedFunction.h.
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.
Standard constructor.
Definition at line 27 of file WThreadedFunction.cpp.
References WSharedObject< T >::getWriteTicket(), and m_status.
WThreadedFunctionBase::~WThreadedFunctionBase | ( | ) | [virtual] |
Destroys the thread pool and stops all threads, if any one of them is still running.
Definition at line 36 of file WThreadedFunction.cpp.
References m_exceptionSignal.
WThreadedFunctionBase::WThreadedFunctionBase | ( | WThreadedFunctionBase const & | ) | [protected] |
WThreadedFunctionBase is non-copyable, so the copy constructor is not implemented.
boost::shared_ptr< WCondition > WThreadedFunctionBase::getThreadsDoneCondition | ( | ) |
Returns a condition that gets fired when all threads have finished.
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.
virtual void WThreadedFunctionBase::run | ( | ) | [pure virtual] |
Starts the threads.
Implemented in WThreadedFunction< Function_T >.
WThreadedFunctionStatus WThreadedFunctionBase::status | ( | ) |
Get the status of the threads.
Definition at line 41 of file WThreadedFunction.cpp.
References WSharedObject< T >::getReadTicket(), and m_status.
Referenced by WThreadedFunctionTest::testExceptionHandling(), WThreadedFunctionTest::testMultipleThreads(), WThreadedFunctionTest::testStopCondition(), and WThreadedFunctionTest::testStopThreads().
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.
func | The 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 >.
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().