7 #ifndef __FWTHREAD_WORKER_HPP__ 8 #define __FWTHREAD_WORKER_HPP__ 10 #include <boost/any.hpp> 11 #include <boost/asio/io_service.hpp> 14 #include <fwCore/base.hpp> 15 #include <fwCore/HiResClock.hpp> 17 #include "fwThread/config.hpp" 21 typedef std::thread::id ThreadIdType;
35 typedef ::fwCore::HiResClock::HiResClockType PeriodType;
36 typedef std::function< void () > TaskType;
37 typedef ::boost::any ExitReturnType;
39 typedef std::shared_future< ExitReturnType > FutureType;
48 FWTHREAD_API
virtual void stop() = 0;
51 virtual void post(TaskType handler) = 0;
64 template<
typename R,
typename CALLABLE >
65 std::shared_future< R > postTask(CALLABLE f);
68 FWTHREAD_API
virtual ThreadIdType getThreadId()
const = 0;
78 virtual FutureType getFuture()
92 FWTHREAD_API
virtual void processTasks(PeriodType maxtime) = 0;
100 FWTHREAD_API
virtual void processTasks() = 0;
106 FWTHREAD_API
static SPTR(
Worker) defaultFactory();
120 #include "fwThread/Worker.hxx" 122 #endif //__FWTHREAD_WORKER_HPP__
Base class for all FW4SPL's classes.
FWTHREAD_API ThreadIdType getCurrentThreadId()
Returns the current thread id.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
The Timer class provides single-shot or repetitive timers. A Timer triggers a function once after a d...
FutureType m_future
Worker's loop future.
This class creates and manages a task loop. The default implementation create a loop in a new thread...
This namespace fwThread provides few tools to execute asynchronous tasks on different threads...