Kea  1.9.9-git
lease_update_backlog.h
Go to the documentation of this file.
1 // Copyright (C) 2020-2021 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 HA_LEASE_BACKLOG_H
8 #define HA_LEASE_BACKLOG_H
9 
10 #include <dhcpsrv/lease.h>
11 #include <deque>
12 #include <mutex>
13 #include <utility>
14 
15 namespace isc {
16 namespace ha {
17 
46 public:
47 
49  enum OpType {
50  ADD,
52  };
53 
58  LeaseUpdateBacklog(const size_t limit);
59 
66  bool push(const OpType op_type, const dhcp::LeasePtr& lease);
67 
73  dhcp::LeasePtr pop(OpType& op_type);
74 
88  bool wasOverflown();
89 
93  void clear();
94 
96  size_t size();
97 
98 private:
99 
106  bool pushInternal(const OpType op_type, const dhcp::LeasePtr& lease);
107 
113  dhcp::LeasePtr popInternal(OpType& op_type);
114 
116  size_t limit_;
117 
119  bool overflown_;
120 
122  std::deque<std::pair<OpType, dhcp::LeasePtr> > outstanding_updates_;
123 
125  std::mutex mutex_;
126 };
127 
128 } // end of namespace isc::ha
129 } // end of namespace isc
130 
131 #endif // HA_LEASE_BACKLOG_H
OpType
Type of the lease update (operation type).
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
Definition: lease.h:26
void clear()
Removes all lease updates from the queue.
LeaseUpdateBacklog(const size_t limit)
Constructor.
bool push(const OpType op_type, const dhcp::LeasePtr &lease)
Appends lease update to the queue.
size_t size()
Returns the current size of the queue.
bool wasOverflown()
Checks if the queue was overflown.
Defines the logger used by the top-level component of kea-dhcp-ddns.
dhcp::LeasePtr pop(OpType &op_type)
Returns the next lease update and removes it from the queue.
Queue holding a backlog of unsent lease updates.