Kea: interval_timer.h Source File

| Kea 2.2.0

interval_timer.h
Go to the documentation of this file.
1// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef ASIOLINK_INTERVAL_TIMER_H
8#define ASIOLINK_INTERVAL_TIMER_H 1
9
10#include <boost/shared_ptr.hpp>
11#include <functional>
12
13#include <asiolink/io_service.h>
14
15namespace isc {
16namespace asiolink {
17
18class IntervalTimerImpl;
19
52 class IntervalTimer {
53public:
55 typedef std::function<void()> Callback;
56
60 enum Mode
61 {
62 REPEATING,
63 ONE_SHOT
64 };
65
71
72private:
73 IntervalTimer(const IntervalTimer& source);
74 IntervalTimer& operator=(const IntervalTimer& source);
75public:
83 IntervalTimer(IOService& io_service);
84
91 ~IntervalTimer();
93
113 void setup(const Callback& cbfunc, const long interval,
114 const Mode& mode = REPEATING);
115
124 void cancel();
125
132 long getInterval() const;
133
134private:
135 boost::shared_ptr<IntervalTimerImpl> impl_;
136};
137
138 typedef boost::shared_ptr<isc::asiolink::IntervalTimer> IntervalTimerPtr;
139
140} // namespace asiolink
141} // namespace isc
142#endif // ASIOLINK_INTERVAL_TIMER_H
isc::asiolink::IOService
The IOService class is a wrapper for the ASIO io_service class.
Definition: io_service.h:33
isc::asiolink::IntervalTimer
The IntervalTimer class is a wrapper for the ASIO boost::asio::deadline_timer class.
Definition: interval_timer.h:52
isc::asiolink::IntervalTimer::~IntervalTimer
~IntervalTimer()
The destructor.
Definition: interval_timer.cc:179
isc::asiolink::IntervalTimer::getInterval
long getInterval() const
Return the timer interval.
Definition: interval_timer.cc:196
isc::asiolink::IntervalTimer::cancel
void cancel()
Cancel the timer.
Definition: interval_timer.cc:191
isc::asiolink::IntervalTimer::Callback
std::function< void()> Callback
Definition: interval_timer.h:55
isc::asiolink::IntervalTimer::setup
void setup(const Callback &cbfunc, const long interval, const Mode &mode=REPEATING)
Register timer callback function and interval.
Definition: interval_timer.cc:185
isc::asiolink::IntervalTimer::Mode
Mode
Defines possible timer modes used to setup a timer.
Definition: interval_timer.h:61
isc::asiolink::IntervalTimer::ONE_SHOT
@ ONE_SHOT
Definition: interval_timer.h:63
isc::asiolink::IntervalTimer::REPEATING
@ REPEATING
Definition: interval_timer.h:62
io_service.h
asiolink
A wrapper interface for the ASIO library.
isc::asiolink::IntervalTimerPtr
boost::shared_ptr< isc::asiolink::IntervalTimer > IntervalTimerPtr
Definition: interval_timer.h:138
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143