Kea  2.3.2-git
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 
15 namespace isc {
16 namespace dhcp {
17 
20 
21 typedef boost::shared_ptr<TimerMgrImpl> TimerMgrImplPtr;
22 
24 class TimerMgr;
25 
27 typedef boost::shared_ptr<TimerMgr> TimerMgrPtr;
28 
62 class TimerMgr : public boost::noncopyable {
63 public:
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,
94  const asiolink::IntervalTimer::Callback& callback,
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 
147 private:
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
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
Definition: timer_mgr.h:24
Implementation of the TimerMgr.
Definition: timer_mgr.cc:83
void cancel(const std::string &timer_name)
Cancels the execution of the interval timer.
Definition: timer_mgr.cc:516
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Timer Manager.
Definition: timer_mgr.cc:526
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:496
~TimerMgr()
Destructor.
Definition: timer_mgr.cc:458
void unregisterTimers()
Unregisters all timers.
Definition: timer_mgr.cc:487
boost::shared_ptr< TimerMgrImpl > TimerMgrImplPtr
Definition: timer_mgr.h:19
Defines the logger used by the top-level component of kea-lfc.
void unregisterTimer(const std::string &timer_name)
Unregisters specified timer.
Definition: timer_mgr.cc:477
void setup(const std::string &timer_name)
Schedules the execution of the interval timer.
Definition: timer_mgr.cc:506
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:463
size_t timersCount() const
Returns the number of registered timers.
Definition: timer_mgr.cc:501
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
Definition: timer_mgr.cc:449