1 #ifndef H_CANOPEN_TIMER 2 #define H_CANOPEN_TIMER 5 #include <boost/asio.hpp> 6 #include <boost/thread/thread.hpp> 7 #include <boost/asio/high_resolution_timer.hpp> 18 boost::mutex::scoped_lock lock(
mutex);
21 template<
typename T>
void start(
const TimerDelegate &del,
const T &dur,
bool start_now =
true){
22 boost::mutex::scoped_lock lock(
mutex);
24 period = boost::chrono::duration_cast<boost::chrono::high_resolution_clock::duration>(dur);
31 boost::mutex::scoped_lock lock(
mutex);
35 const boost::chrono::high_resolution_clock::duration &
getPeriod(){
36 boost::mutex::scoped_lock lock(
mutex);
45 boost::asio::io_service
io;
46 boost::asio::io_service::work
work;
47 boost::asio::basic_waitable_timer<boost::chrono::high_resolution_clock>
timer;
48 boost::chrono::high_resolution_clock::duration
period;
53 void handler(
const boost::system::error_code& ec){
55 boost::mutex::scoped_lock lock(mutex);
57 timer.expires_at(timer.expires_at() +
period);
boost::asio::io_service io
void start(const TimerDelegate &del, const T &dur, bool start_now=true)
void handler(const boost::system::error_code &ec)
const boost::chrono::high_resolution_clock::duration & getPeriod()
boost::asio::basic_waitable_timer< boost::chrono::high_resolution_clock > timer
void run(ClassLoader *loader)
boost::chrono::high_resolution_clock::duration period
boost::asio::io_service::work work
fastdelegate::FastDelegate0< bool > TimerDelegate