![]() |
OpenWalnut
1.5.0dev
|
A worker thread that belongs to a. More...
#include <WWorkerThread.h>
Inheritance diagram for WWorkerThread< Function_T >:
Collaboration diagram for WWorkerThread< Function_T >:Public Types | |
| typedef boost::function< void() > | StopFunction |
| a type for stop callbacks More... | |
| typedef boost::function< void(WException const &) > | ExceptionFunction |
| a type for exception callbacks More... | |
Public Types inherited from WThreadedRunner | |
| typedef std::shared_ptr< WThreadedRunner > | SPtr |
| Abbreviation to a shared_ptr to this type. More... | |
| typedef std::shared_ptr< const WThreadedRunner > | ConstSPtr |
| Abbreviation to a const shared_ptr to this type. More... | |
| typedef boost::function< void(void) > | THREADFUNCTION |
| Type used for simple thread functions. More... | |
Public Member Functions | |
| WWorkerThread (std::shared_ptr< Function_T > func, std::size_t id, std::size_t numThreads) | |
| Default constructor. More... | |
| virtual | ~WWorkerThread () |
| Default destructor. More... | |
| void | subscribeExceptionSignal (ExceptionFunction func) |
| Subscribe a function to the exception signal. More... | |
| void | subscribeStopSignal (StopFunction func) |
| Subscribe a function to the stop signal. More... | |
Public Member Functions inherited from WThreadedRunner | |
| WThreadedRunner () | |
| Default constructor. More... | |
| virtual | ~WThreadedRunner () |
| Destructor. More... | |
| virtual void | run () |
| Run thread. More... | |
| void | run (THREADFUNCTION f) |
| Run thread. More... | |
| void | wait (bool requestFinish=false) |
| Wait for the thread to be finished. More... | |
| virtual void | requestStop () |
| This method's purpose is to request a stop without waiting for it. More... | |
| virtual boost::signals2::connection | subscribeSignal (THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier) |
| Connects a specified notify function with a signal this thread instance is offering. More... | |
| const WBoolFlag & | isCrashed () const |
| Checks whether this thread has been crashed. More... | |
| const std::string & | getCrashMessage () const |
| Get the message of the exception finally causing the crash. More... | |
| void | setThreadName (std::string name) |
| Set the name of the thread. More... | |
| std::string | getThreadName () const |
| Returns the current thread name. More... | |
Protected Member Functions | |
| virtual void | threadMain () |
| The thread's main function. More... | |
Protected Member Functions inherited from WThreadedRunner | |
| virtual void | notifyStop () |
| Gets called when the thread should be stopped. More... | |
| void | yield () const |
| Give remaining execution timeslice to another thread. More... | |
| void | sleep (const int32_t t) const |
| Sets thread asleep. More... | |
| void | msleep (const int32_t t) const |
| Sets thread asleep. More... | |
| void | waitForStop () |
| Let the thread sleep until a stop request was given. More... | |
| virtual void | onThreadException (const WException &e) |
| This method is called if an exception was caught, which came from the custom thread code. More... | |
| void | handleDeadlyException (const WException &e, std::string sender="WThreadedRunner") |
| Handle the specified exception which was not caught in the thread, which basically means the thread has crashed. More... | |
Private Types | |
| typedef boost::signals2::signal< void() > | StopSignal |
| a type for stop signals More... | |
| typedef boost::signals2::signal< void(WException const &) > | ExceptionSignal |
| a type for exception signals More... | |
Private Member Functions | |
| WWorkerThread (WWorkerThread const &) | |
| WWorkerThread is non-copyable, so the copy constructor is not implemented. More... | |
| WWorkerThread & | operator= (WWorkerThread const &) |
| WWorkerThread is non-copyable, so the copy operator is not implemented. More... | |
Private Attributes | |
| std::shared_ptr< Function_T > | m_func |
| the functor called in threadMain() More... | |
| std::size_t | m_id |
| a thread id between 0 and m_numThreads - 1 More... | |
| std::size_t | m_numThreads |
| the number of threads More... | |
| ExceptionSignal | m_exceptionSignal |
| the exception signal More... | |
| StopSignal | m_stopSignal |
| the stop signal More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from WThreadedRunner | |
| static void | setThisThreadName (std::string name) |
| Static function to set the name of the calling thread. More... | |
Protected Attributes inherited from WThreadedRunner | |
| boost::thread | m_thread |
| Thread instance. More... | |
| WBoolFlag | m_shutdownFlag |
| Condition getting fired whenever the thread should quit. More... | |
| WBoolFlag | m_isCrashed |
| True whenever an exception is thrown during threadMain. More... | |
| std::string | m_crashMessage |
| The crash message. More... | |
A worker thread that belongs to a.
Definition at line 42 of file WWorkerThread.h.
| typedef boost::function< void ( WException const& ) > WWorkerThread< Function_T >::ExceptionFunction |
a type for exception callbacks
Definition at line 57 of file WWorkerThread.h.
|
private |
a type for exception signals
Definition at line 49 of file WWorkerThread.h.
| typedef boost::function< void () > WWorkerThread< Function_T >::StopFunction |
a type for stop callbacks
Definition at line 54 of file WWorkerThread.h.
|
private |
a type for stop signals
Definition at line 46 of file WWorkerThread.h.
| WWorkerThread< Function_T >::WWorkerThread | ( | std::shared_ptr< Function_T > | func, |
| std::size_t | id, | ||
| std::size_t | numThreads | ||
| ) |
Default constructor.
| func | A pointer to the function object. |
| id | A thread id. |
| numThreads | The number of threads. |
Definition at line 123 of file WWorkerThread.h.
References WWorkerThread< Function_T >::m_func.
|
virtual |
Default destructor.
Definition at line 141 of file WWorkerThread.h.
|
private |
WWorkerThread is non-copyable, so the copy constructor is not implemented.
|
private |
WWorkerThread is non-copyable, so the copy operator is not implemented.
| void WWorkerThread< Function_T >::subscribeExceptionSignal | ( | ExceptionFunction | func | ) |
Subscribe a function to the exception signal.
| func | The function. |
Definition at line 148 of file WWorkerThread.h.
Referenced by WWorkerThreadTest::testExceptions().
Here is the caller graph for this function:| void WWorkerThread< Function_T >::subscribeStopSignal | ( | StopFunction | func | ) |
Subscribe a function to the stop signal.
| func | The function. |
Definition at line 157 of file WWorkerThread.h.
Referenced by WWorkerThreadTest::testSingleThread(), and WWorkerThreadTest::testStopThread().
Here is the caller graph for this function:
|
protectedvirtual |
The thread's main function.
Reimplemented from WThreadedRunner.
Definition at line 166 of file WWorkerThread.h.
References WException::what().
Here is the call graph for this function:
|
private |
the exception signal
Definition at line 116 of file WWorkerThread.h.
|
private |
the functor called in threadMain()
Definition at line 107 of file WWorkerThread.h.
Referenced by WWorkerThread< Function_T >::WWorkerThread().
|
private |
a thread id between 0 and m_numThreads - 1
Definition at line 110 of file WWorkerThread.h.
|
private |
the number of threads
Definition at line 113 of file WWorkerThread.h.
|
private |
the stop signal
Definition at line 119 of file WWorkerThread.h.