25 #ifndef WWORKERTHREAD_H
26 #define WWORKERTHREAD_H
31 #include <boost/shared_ptr.hpp>
32 #include <boost/signal.hpp>
35 #include "WException.h"
36 #include "WThreadedRunner.h"
41 template<
class Function_T >
66 WWorkerThread( boost::shared_ptr< Function_T > func, std::size_t
id, std::size_t numThreads );
122 template<
class Function_T >
126 m_numThreads( numThreads ),
130 if(
id >= numThreads )
132 throw WException( std::string(
"The id of this thread is not valid." ) );
136 throw WException( std::string(
"No thread function provided!" ) );
140 template<
class Function_T >
143 m_exceptionSignal.disconnect_all_slots();
144 m_stopSignal.disconnect_all_slots();
147 template<
class Function_T >
152 m_exceptionSignal.connect( func );
156 template<
class Function_T >
161 m_stopSignal.connect( func );
165 template<
class Function_T >
172 m_func->operator() ( m_id, m_numThreads, m_shutdownFlag );
176 m_exceptionSignal( e );
179 catch( std::exception
const& e )
182 m_exceptionSignal( w );
187 WException w( std::string(
"An exception was thrown." ) );
188 m_exceptionSignal( w );
195 #endif // WWORKERTHREAD_H