Kea  2.1.7-git
isc::dhcp::ResourceHandler Class Reference

Resource race avoidance RAII handler. More...

#include <resource_handler.h>

+ Inheritance diagram for isc::dhcp::ResourceHandler:

Public Member Functions

 ResourceHandler ()
 Constructor. More...
 
virtual ~ResourceHandler ()
 Destructor. More...
 
bool isLocked (Lease::Type type, const asiolink::IOAddress &addr)
 Checks if a resource is owned by this handler. More...
 
bool tryLock (Lease::Type type, const asiolink::IOAddress &addr)
 Tries to acquires a resource. More...
 
void unLock (Lease::Type type, const asiolink::IOAddress &addr)
 Releases a resource. More...
 

Detailed Description

Resource race avoidance RAII handler.

Definition at line 34 of file resource_handler.h.

Constructor & Destructor Documentation

◆ ResourceHandler()

isc::dhcp::ResourceHandler::ResourceHandler ( )

Constructor.

Definition at line 23 of file resource_handler.cc.

◆ ~ResourceHandler()

isc::dhcp::ResourceHandler::~ResourceHandler ( )
virtual

Destructor.

Releases owned resources.

Definition at line 26 of file resource_handler.cc.

References isc::asiolink::IOAddress::toBytes().

+ Here is the call graph for this function:

Member Function Documentation

◆ isLocked()

bool isc::dhcp::ResourceHandler::isLocked ( Lease::Type  type,
const asiolink::IOAddress addr 
)

Checks if a resource is owned by this handler.

Parameters
typeType of the resource, member of Lease::Type enum.
addrThe address or prefix aka the resource.
Returns
true if this handler owns the resource, false otherwise.

Definition at line 77 of file resource_handler.cc.

References isc::asiolink::IOAddress::toBytes().

+ Here is the call graph for this function:

◆ tryLock()

bool isc::dhcp::ResourceHandler::tryLock ( Lease::Type  type,
const asiolink::IOAddress addr 
)

Tries to acquires a resource.

Lookup the resource, if not found insert the resource in the resource container and return true, if found return false

Parameters
typeType of the resource, member of Lease::Type enum.
addrThe address or prefix aka the resource.
Returns
true if the resource was acquired, false if the resource is busy i.e. owned by a handler.

Definition at line 64 of file resource_handler.cc.

Referenced by isc::dhcp::AllocEngine::allocateLeases6(), isc::lease_cmds::LeaseCmdsImpl::lease6BulkApplyHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6UpdateHandler(), and isc::lease_cmds::LeaseCmdsImpl::leaseAddHandler().

◆ unLock()

void isc::dhcp::ResourceHandler::unLock ( Lease::Type  type,
const asiolink::IOAddress addr 
)

Releases a resource.

Remove the resource from the resource container.

Parameters
typeType of the resource, member of Lease::Type enum.
addrThe address or prefix aka the resource.
Exceptions
whenwe do not own the resource.

Definition at line 85 of file resource_handler.cc.

References isc_throw, isc::asiolink::IOAddress::toBytes(), isc::asiolink::IOAddress::toText(), and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: