12#include <boost/enable_shared_from_this.hpp> 
   13#include <boost/noncopyable.hpp> 
   14#include <boost/shared_ptr.hpp> 
   23namespace ph = std::placeholders;
 
   36    public boost::enable_shared_from_this<IntervalTimerImpl>,
 
   37    public boost::noncopyable {
 
   59    void callback(
const boost::system::error_code& error);
 
   63        lock_guard<mutex> lk (mutex_);
 
   66        cbfunc_ = std::function<void()>();
 
 
   85    std::atomic<long> interval_;
 
   91    boost::asio::deadline_timer timer_;
 
  103    static const long INVALIDATED_INTERVAL = -1;
 
 
  107    interval_(0), io_service_(io_service), timer_(io_service_->getInternalIOService()),
 
 
  112    interval_ = INVALIDATED_INTERVAL;
 
 
  129    lock_guard<mutex> lk(mutex_);
 
  131    interval_ = interval;
 
 
  141IntervalTimerImpl::update() {
 
  144        timer_.expires_from_now(boost::posix_time::millisec(
long(interval_)));
 
  150    } 
catch (
const boost::system::system_error& e) {
 
  152    } 
catch (
const boost::bad_weak_ptr&) {
 
  159    if (interval_ == INVALIDATED_INTERVAL) {
 
  162    if (interval_ == 0 || ec) {
 
  166            lock_guard<mutex> lk(mutex_);
 
 
  190    return (impl_->setup(cbfunc, interval, mode));
 
 
  200    return (impl_->getInterval());
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
A generic exception that is thrown when an unexpected error condition occurs.
This class holds a call back function of asynchronous operations.
long getInterval() const
Get the timer interval.
~IntervalTimerImpl()
Destructor.
void callback(const boost::system::error_code &error)
Callback function which calls the registerd callback.
void cancel()
Cancel timer.
void setup(const IntervalTimer::Callback &cbfunc, const long interval, const IntervalTimer::Mode &interval_mode=IntervalTimer::REPEATING)
Setup function to register callback and start timer.
IntervalTimerImpl(const IOServicePtr &io_service)
Constructor.
The IntervalTimer class is a wrapper for the ASIO boost::asio::deadline_timer class.
~IntervalTimer()
The destructor.
long getInterval() const
Return the timer interval.
void cancel()
Cancel the timer.
std::function< void()> Callback
void setup(const Callback &cbfunc, const long interval, const Mode &mode=REPEATING)
Register timer callback function and interval.
Mode
Defines possible timer modes used to setup a timer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Defines the logger used by the top-level component of kea-lfc.