12 #include <boost/bind.hpp> 13 #include <boost/enable_shared_from_this.hpp> 14 #include <boost/shared_ptr.hpp> 29 public boost::enable_shared_from_this<IntervalTimerImpl>
41 void callback(
const boost::system::error_code& error);
55 boost::asio::deadline_timer timer_;
62 static const long INVALIDATED_INTERVAL = -1;
65 IntervalTimerImpl::IntervalTimerImpl(
IOService& io_service) :
66 interval_(0), timer_(io_service.get_io_service()),
71 interval_ = INVALIDATED_INTERVAL;
99 IntervalTimerImpl::update() {
102 timer_.expires_from_now(boost::posix_time::millisec(interval_));
107 boost::asio::placeholders::error));
108 }
catch (
const boost::system::system_error& e) {
110 }
catch (
const boost::bad_weak_ptr&) {
118 assert(interval_ != INVALIDATED_INTERVAL);
119 if (interval_ == 0 || ec) {
144 return (impl_->setup(cbfunc, interval, mode));
154 return (impl_->getInterval());
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
This class holds a call back function of asynchronous operations.
void cancel()
Cancel the timer.
long getInterval() const
Return the timer interval.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOService class is a wrapper for the ASIO io_service class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IntervalTimer class is a wrapper for the ASIO boost::asio::deadline_timer class.
A generic exception that is thrown when an unexpected error condition occurs.
Mode
Defines possible timer modes used to setup a timer.
~IntervalTimer()
The destructor.
void setup(const IntervalTimer::Callback &cbfunc, const long interval, const IntervalTimer::Mode &interval_mode=IntervalTimer::REPEATING)
Defines the logger used by the top-level component of kea-dhcp-ddns.
A wrapper interface for the ASIO library.
boost::function< void()> Callback
void callback(const boost::system::error_code &error)
void setup(const Callback &cbfunc, const long interval, const Mode &mode=REPEATING)
Register timer callback function and interval.