Lightweight 0.20260303.0
Loading...
Searching...
No Matches
Lightweight::Pool< Config > Class Template Reference

#include <Pool.hpp>

Classes

class  PooledDataMapper
 

Public Member Functions

 Pool ()
 
 ~Pool () noexcept=default
 
 Pool (Pool const &)=delete
 
Pooloperator= (Pool const &)=delete
 
 Pool (Pool &&)=delete
 
Pooloperator= (Pool &&)=delete
 
PooledDataMapper Acquire ()
 
PooledDataMapper Acquire ()
 

Detailed Description

template<PoolConfig Config>
class Lightweight::Pool< Config >

A thread-safe pool of DataMapper instances with the policy configured by the PoolConfig template parameter. The pool allows acquiring and returning DataMapper instances, and manages the lifecycle of these instances according to the specified growth strategy.

Definition at line 53 of file Pool.hpp.

Constructor & Destructor Documentation

◆ Pool()

template<PoolConfig Config>
Lightweight::Pool< Config >::Pool ( )
inlineexplicit

Default constructor that pre-creates the initial number of data mappers and stores them in the pool No other constructors are provided, as the pool is configured at compile time via the template parameter

Definition at line 147 of file Pool.hpp.

◆ ~Pool()

template<PoolConfig Config>
Lightweight::Pool< Config >::~Pool ( )
defaultnoexcept

Default destructor, the pool manages the lifecycle of the data mappers, so no special cleanup is needed bug be aware that any acquired data mappers that are not returned to the pool will be destroyed when the pool is destroyed, which may lead to resource leaks if not handled properly

Member Function Documentation

◆ Acquire() [1/2]

template<PoolConfig Config>
PooledDataMapper Lightweight::Pool< Config >::Acquire ( )
inline

Function to acquire a data mapper from the pool, the behavior of this function depends on the growth strategy this is a specific implementation for the BoundedWait strategy, which blocks until a data mapper is available if the pool is at maximum capacity

Definition at line 167 of file Pool.hpp.

◆ Acquire() [2/2]

template<PoolConfig Config>
PooledDataMapper Lightweight::Pool< Config >::Acquire ( )
inline

Function to acquire a data mapper from the pool, the behavior of this function depends on the growth strategy this is a specific implementation for the strategies that do not block, which always creates a new data mapper if the pool is empty, regardless of the maximum capacity

Definition at line 196 of file Pool.hpp.


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