Kea 2.7.6
timer_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2015-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 TIMER_MGR_H
8#define TIMER_MGR_H
9
11#include <boost/noncopyable.hpp>
12#include <boost/shared_ptr.hpp>
13#include <string>
14
15namespace isc {
16namespace dhcp {
17
19class TimerMgrImpl;
20
21typedef boost::shared_ptr<TimerMgrImpl> TimerMgrImplPtr;
22
24class TimerMgr;
25
27typedef boost::shared_ptr<TimerMgr> TimerMgrPtr;
28
62class TimerMgr : public boost::noncopyable {
63public:
64
66 static const TimerMgrPtr& instance();
67
72 ~TimerMgr();
73
77 void setIOService(const asiolink::IOServicePtr& io_service);
78
80
81
93 void registerTimer(const std::string& timer_name,
95 const long interval,
96 const asiolink::IntervalTimer::Mode& scheduling_mode);
97
106 void unregisterTimer(const std::string& timer_name);
107
109 void unregisterTimers();
110
116 bool isTimerRegistered(const std::string& timer_name);
117
119 size_t timersCount() const;
120
133 void setup(const std::string& timer_name);
134
143 void cancel(const std::string& timer_name);
144
146
147private:
148
154 TimerMgr();
155
157 TimerMgrImplPtr impl_;
158};
159
160} // end of namespace isc::dhcp
161} // end of namespace isc
162
163#endif // TIMER_MGR_H
Manages a pool of asynchronous interval timers.
Definition timer_mgr.h:62
bool isTimerRegistered(const std::string &timer_name)
Checks if the timer with a specified name has been registered.
Definition timer_mgr.cc:493
~TimerMgr()
Destructor.
Definition timer_mgr.cc:455
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Timer Manager.
Definition timer_mgr.cc:523
void setup(const std::string &timer_name)
Schedules the execution of the interval timer.
Definition timer_mgr.cc:503
size_t timersCount() const
Returns the number of registered timers.
Definition timer_mgr.cc:498
void unregisterTimers()
Unregisters all timers.
Definition timer_mgr.cc:484
void cancel(const std::string &timer_name)
Cancels the execution of the interval timer.
Definition timer_mgr.cc:513
void registerTimer(const std::string &timer_name, const asiolink::IntervalTimer::Callback &callback, const long interval, const asiolink::IntervalTimer::Mode &scheduling_mode)
Registers new timer in the TimerMgr.
Definition timer_mgr.cc:460
void unregisterTimer(const std::string &timer_name)
Unregisters specified timer.
Definition timer_mgr.cc:474
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
Definition timer_mgr.cc:446
boost::shared_ptr< TimerMgrImpl > TimerMgrImplPtr
Definition timer_mgr.h:21
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
Definition timer_mgr.h:27
Defines the logger used by the top-level component of kea-lfc.