|
| DynamicObjectPool (std::size_t maxPoolSize=DEFAULT_POOL_SIZE, std::size_t initialSize=0) |
|
| ~DynamicObjectPool () |
| A destructor for this class that deletes all objects in the pool.
|
|
std::unique_ptr< T > | acquireObject () |
| Acquires a unique pointer to an object from the pool. More...
|
|
T * | acquireObjectRaw () |
| Acquires a raw pointer to an object from the pool. More...
|
|
void | releaseObject (std::unique_ptr< T > obj) |
| Releases a unique pointer to an object back to the pool. More...
|
|
void | releaseObjectRaw (T *obj) |
| Releases a raw pointer to an object back to the pool. More...
|
|
std::size_t | size () const |
| Gets the current number of objects in the pool.
|
|
std::size_t | maxSize () const |
| Gets the maximum number of objects in the pool.
|
|
void | setMaxSize (std::size_t maxSize) |
| Sets the maximum number of objects in the pool.
|
|
void | preallocate (std::size_t count) |
| Pre-allocates up to a minimum number of objects in the pool. More...
|
|
void | clear () |
| Deallocates and releases all objects currently held by the pool.
|
|
template<class T, std::enable_if_t< std::is_default_constructible< T >::value, bool > = true>
class pcpp::internal::DynamicObjectPool< T, >
A generic object pool implementation.
This class provides a generic object pool that can be used to efficiently manage and reuse objects of any type. Objects can be acquired from the pool using the acquireObject
method, and released back to the pool using the releaseObject
method. If the pool is empty when acquiring an object, a new object will be created. If the pool is full when releasing an object, the object will be deleted.
- Template Parameters
-
T | The type of objects managed by the pool. Must be default constructable. |