Kea 2.5.8
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.
 
virtual ~ResourceHandler ()
 Destructor.
 
bool isLocked (Lease::Type type, const asiolink::IOAddress &addr)
 Checks if a resource is owned by this handler.
 
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.
 

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.

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().

Referenced by isc::dhcp::ResourceHandler4::isLocked4().

+ 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::lease_cmds::LeaseCmdsImpl::lease6BulkApplyHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6UpdateHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseAddHandler(), and isc::dhcp::ResourceHandler4::tryLock4().

◆ 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().

Referenced by isc::dhcp::ResourceHandler4::unLock4().

+ Here is the call graph for this function:

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