Kea: timer_mgr.h Source File

| Kea 3.0.0

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
10#include <asiolink/interval_timer.h>
11#include <boost/noncopyable.hpp>
12#include <boost/shared_ptr.hpp>
13#include <string>
14
15namespace isc {
16namespace dhcp {
17
19class TimerMgrImpl;
20
21 typedef boost::shared_ptr<TimerMgrImpl> TimerMgrImplPtr;
22
24class TimerMgr;
25
27 typedef boost::shared_ptr<TimerMgr> TimerMgrPtr;
28
62 class 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,
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
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
isc::asiolink::IntervalTimer::Callback
std::function< void()> Callback
Definition interval_timer.h:55
isc::asiolink::IntervalTimer::Mode
Mode
Defines possible timer modes used to setup a timer.
Definition interval_timer.h:61
isc::dhcp::TimerMgrImpl
Implementation of the TimerMgr.
Definition timer_mgr.cc:83
isc::dhcp::TimerMgr
Manages a pool of asynchronous interval timers.
Definition timer_mgr.h:62
isc::dhcp::TimerMgr::isTimerRegistered
bool isTimerRegistered(const std::string &timer_name)
Checks if the timer with a specified name has been registered.
Definition timer_mgr.cc:493
isc::dhcp::TimerMgr::~TimerMgr
~TimerMgr()
Destructor.
Definition timer_mgr.cc:455
isc::dhcp::TimerMgr::setIOService
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Timer Manager.
Definition timer_mgr.cc:523
isc::dhcp::TimerMgr::setup
void setup(const std::string &timer_name)
Schedules the execution of the interval timer.
Definition timer_mgr.cc:503
isc::dhcp::TimerMgr::timersCount
size_t timersCount() const
Returns the number of registered timers.
Definition timer_mgr.cc:498
isc::dhcp::TimerMgr::unregisterTimers
void unregisterTimers()
Unregisters all timers.
Definition timer_mgr.cc:484
isc::dhcp::TimerMgr::cancel
void cancel(const std::string &timer_name)
Cancels the execution of the interval timer.
Definition timer_mgr.cc:513
isc::dhcp::TimerMgr::registerTimer
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
isc::dhcp::TimerMgr::unregisterTimer
void unregisterTimer(const std::string &timer_name)
Unregisters specified timer.
Definition timer_mgr.cc:474
isc::dhcp::TimerMgr::instance
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
Definition timer_mgr.cc:446
interval_timer.h
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:28
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::TimerMgrImplPtr
boost::shared_ptr< TimerMgrImpl > TimerMgrImplPtr
Definition timer_mgr.h:21
isc::dhcp::TimerMgrPtr
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
Definition timer_mgr.h:27
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148