intnslib 0.1
A library to hold common functionality used across multiple projects.
Loading...
Searching...
No Matches
intns::memory::PoolLease< Pool > Class Template Reference

RAII wrapper for managing leased ObjectPool objects. More...

#include <ObjectPool.hpp>

Public Member Functions

 PoolLease (Pool &p)
 Creates a PoolLease and acquires an object from the given pool.
 
 PoolLease (PoolLease &&o) noexcept
 Move constructor for PoolLease. Transfers ownership and deactivates the source to prevent double release.
 
 PoolLease (const PoolLease &)=delete
 
PoolLeaseoperator= (const PoolLease &)=delete
 
 ~PoolLease ()
 Destructor for the PoolLease class.
 
auto & get () noexcept
 Returns a reference to the internal object.
 
value_type * operator-> () noexcept
 Provides pointer-like access to the underlying object.
 
const auto & get () const noexcept
 Returns a constant reference to the managed object.
 
const value_type * operator-> () const noexcept
 Provides pointer-like access to the underlying object.
 
value_type release () noexcept
 Releases ownership of the managed object.
 

Detailed Description

template<typename Pool>
class intns::memory::PoolLease< Pool >

RAII wrapper for managing leased ObjectPool objects.

PoolLease acquires an ObjectPool object on creation and releases it on destruction unless explicitly released; guarantees exception safety and prevents leaks.

Template Parameters
PoolThe ObjectPool providing value_type, take(), and add() methods.

Constructor & Destructor Documentation

◆ PoolLease() [1/2]

template<typename Pool >
intns::memory::PoolLease< Pool >::PoolLease ( Pool &  p)
inline

Creates a PoolLease and acquires an object from the given pool.

Parameters
pReference to the Pool to lease from.

◆ PoolLease() [2/2]

template<typename Pool >
intns::memory::PoolLease< Pool >::PoolLease ( PoolLease< Pool > &&  o)
inlinenoexcept

Move constructor for PoolLease. Transfers ownership and deactivates the source to prevent double release.

Parameters
oThe PoolLease instance to move from.

Member Function Documentation

◆ get() [1/2]

template<typename Pool >
const auto & intns::memory::PoolLease< Pool >::get ( ) const
inlinenoexcept

Returns a constant reference to the managed object.

Returns
const reference to the object stored in the pool.

◆ get() [2/2]

template<typename Pool >
auto & intns::memory::PoolLease< Pool >::get ( )
inlinenoexcept

Returns a reference to the internal object.

Returns
Reference to the stored object.

◆ operator->() [1/2]

template<typename Pool >
const value_type * intns::memory::PoolLease< Pool >::operator-> ( ) const
inlinenoexcept

Provides pointer-like access to the underlying object.

Returns
A constant pointer to the managed object.

◆ operator->() [2/2]

template<typename Pool >
value_type * intns::memory::PoolLease< Pool >::operator-> ( )
inlinenoexcept

Provides pointer-like access to the underlying object.

Returns
A pointer to the managed object.

◆ release()

template<typename Pool >
value_type intns::memory::PoolLease< Pool >::release ( )
inlinenoexcept

Releases ownership of the managed object.

Marks the object inactive and returns it, transferring ownership; it is no longer considered active.

Returns
value_type The managed object, moved out of this instance.
Note
This function is noexcept and guarantees not to throw exceptions.

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