Kea: isc::dhcp::ResourceHandler Class Reference

| Kea 2.2.0

Classes | Public Member Functions | List of all members
isc::dhcp::ResourceHandler Class Reference

Resource race avoidance RAII handler. More...

`#include <resource_handler.h>`

Inheritance diagram for isc::dhcp::ResourceHandler:
[legend]

## 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.

## 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

  type | Type of the resource, member of `Lease::Type` enum.
  addr | The 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

  type | Type of the resource, member of `Lease::Type` enum.
  addr | The 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

  type | Type of the resource, member of `Lease::Type` enum.
  addr | The address or prefix aka the resource.

Exceptions

  when | we 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:

- resource_handler.h
- resource_handler.cc