Kea 1.5.0
timer_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2015-2017 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
22class TimerMgr;
23
25typedef boost::shared_ptr<TimerMgr> TimerMgrPtr;
26
54class TimerMgr : public boost::noncopyable {
55public:
56
58 static const TimerMgrPtr& instance();
59
64 ~TimerMgr();
65
69 void setIOService(const asiolink::IOServicePtr& io_service);
70
72
73
85 void registerTimer(const std::string& timer_name,
87 const long interval,
88 const asiolink::IntervalTimer::Mode& scheduling_mode);
89
98 void unregisterTimer(const std::string& timer_name);
99
101 void unregisterTimers();
102
108 bool isTimerRegistered(const std::string& timer_name);
109
111 size_t timersCount() const;
112
125 void setup(const std::string& timer_name);
126
135 void cancel(const std::string& timer_name);
136
138
139private:
140
146 TimerMgr();
147
149 TimerMgrImpl* impl_;
150
151};
152
153} // end of namespace isc::dhcp
154} // end of namespace isc
155
156#endif // TIMER_MGR_H
Implementation of the TimerMgr.
Definition: timer_mgr.cc:73
Manages a pool of asynchronous interval timers.
Definition: timer_mgr.h:54
bool isTimerRegistered(const std::string &timer_name)
Checks if the timer with a specified name has been registered.
Definition: timer_mgr.cc:367
~TimerMgr()
Destructor.
Definition: timer_mgr.cc:328
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Timer Manager.
Definition: timer_mgr.cc:397
void setup(const std::string &timer_name)
Schedules the execution of the interval timer.
Definition: timer_mgr.cc:377
size_t timersCount() const
Returns the number of registered timers.
Definition: timer_mgr.cc:372
void unregisterTimers()
Unregisters all timers.
Definition: timer_mgr.cc:358
void cancel(const std::string &timer_name)
Cancels the execution of the interval timer.
Definition: timer_mgr.cc:387
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:334
void unregisterTimer(const std::string &timer_name)
Unregisters specified timer.
Definition: timer_mgr.cc:348
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
Definition: timer_mgr.cc:319
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
Definition: timer_mgr.h:25
Defines the logger used by the top-level component of kea-dhcp-ddns.