7#ifndef RESOURCE_HANDLER_H
8#define RESOURCE_HANDLER_H
13#include <boost/noncopyable.hpp>
14#include <boost/multi_index_container.hpp>
15#include <boost/multi_index/composite_key.hpp>
16#include <boost/multi_index/hashed_index.hpp>
17#include <boost/multi_index/member.hpp>
18#include <boost/multi_index/mem_fun.hpp>
19#include <boost/shared_ptr.hpp>
84 : type_(type), addr_(addr) {
94 std::vector<uint8_t> toBytes()
const {
100 typedef boost::shared_ptr<Resource> ResourcePtr;
103 typedef boost::multi_index_container<
109 boost::multi_index::indexed_by<
112 boost::multi_index::hashed_unique<
113 boost::multi_index::composite_key<
116 boost::multi_index::member<
120 boost::multi_index::const_mem_fun<
121 Resource, std::vector<uint8_t>, &Resource::toBytes
134 static ResourceContainer resources_;
137 static std::mutex mutex_;
173 ResourceContainer owned_;
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
Thrown by lock users when a resource lock cannot be obtained.
ResourceBusy(const char *file, size_t line, const char *what)
Resource race avoidance RAII handler for DHCPv4.
void unLock4(const asiolink::IOAddress &addr)
Releases a resource.
bool isLocked4(const asiolink::IOAddress &addr)
Checks if a resource is owned by this handler.
virtual ~ResourceHandler4()
Destructor.
bool tryLock4(const asiolink::IOAddress &addr)
Tries to acquires a resource.
Resource race avoidance RAII handler.
virtual ~ResourceHandler()
Destructor.
bool tryLock(Lease::Type type, const asiolink::IOAddress &addr)
Tries to acquires a resource.
void unLock(Lease::Type type, const asiolink::IOAddress &addr)
Releases a resource.
ResourceHandler()
Constructor.
bool isLocked(Lease::Type type, const asiolink::IOAddress &addr)
Checks if a resource is owned by this handler.
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.