19mutex ResourceHandler::mutex_;
21ResourceHandler::ResourceContainer ResourceHandler::resources_;
27 lock_guard<mutex> lock_(mutex_);
28 for (
auto const& res : owned_) {
29 unLockInternal(res->type_, res->addr_);
34ResourceHandler::ResourcePtr
36 auto key = boost::make_tuple(type, addr.
toBytes());
37 auto it = resources_.find(key);
38 if (it == resources_.end()) {
39 return (ResourcePtr());
46 ResourcePtr res(
new Resource(type, addr));
48 resources_.insert(res);
55 auto key = boost::make_tuple(type, addr.
toBytes());
56 auto it = resources_.find(key);
57 if (it == resources_.end()) {
67 lock_guard<mutex> lock_(mutex_);
68 holder = lookup(type, addr);
78 auto key = boost::make_tuple(type, addr.
toBytes());
79 lock_guard<mutex> lock_(mutex_);
80 auto it = owned_.find(key);
81 return (it != owned_.end());
86 auto key = boost::make_tuple(type, addr.
toBytes());
87 lock_guard<mutex> lock_(mutex_);
88 auto it = owned_.find(key);
89 if (it == owned_.end()) {
93 unLockInternal(type, addr);
A generic exception that is thrown when an object can not be found.
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
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.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
static std::string typeToText(Type type)
returns text representation of a lease type