7 #ifndef __FWTHREAD_TIMER_HPP__ 8 #define __FWTHREAD_TIMER_HPP__ 10 #include "fwThread/config.hpp" 11 #include "fwThread/Worker.hpp" 13 #include <fwCore/mt/types.hpp> 33 typedef std::shared_ptr< Timer > sptr;
34 typedef std::function< void () > FunctionType;
35 typedef std::chrono::duration<double> TimeDurationType;
38 FWTHREAD_API ~
Timer();
41 FWTHREAD_API
virtual void start() = 0;
44 FWTHREAD_API
virtual void stop()
49 FWTHREAD_API
virtual void setDuration(TimeDurationType duration) = 0;
52 template<
typename F >
55 ::fwCore::mt::ScopedLock lock(m_mutex);
61 virtual bool isOneShot()
const = 0;
64 virtual void setOneShot(
bool oneShot) = 0;
67 virtual bool isRunning()
const = 0;
78 Timer(
const Timer& );
81 Timer& operator=(
const Timer& );
91 mutable ::fwCore::mt::Mutex m_mutex;
96 #endif //__FWTHREAD_TIMER_HPP__ Base class for all FW4SPL's classes.
void setFunction(F f)
Sets the function to be triggered when time duration expires.
FunctionType m_function
Function object to execute each time the timer expires.
virtual FWTHREAD_API void updatedFunction()
This method is triggered when Timer's function is changed.
The Timer class provides single-shot or repetitive timers. A Timer triggers a function once after a d...
virtual FWTHREAD_API void stop()
Stops the timer and cancel all pending operations.
This namespace fwThread provides few tools to execute asynchronous tasks on different threads...