object_pool_pattern::ObjectPool
-
class ObjectPool
Generic Object Pool for managing reusable objects.
This class provides a mechanism to borrow and return objects of type
Reusable. By reusing objects, the Object Pool reduces the overhead of frequent object creation and destruction, especially in performance-critical systems.Public Functions
-
std::unique_ptr<Reusable> borrowObject()
Borrow an object from the pool.
Retrieves an object from the pool for use. If no objects are available, the method throws a
std::runtime_error.- Throws:
std::runtime_error – if the pool is empty and no objects are available.
- Returns:
A unique pointer to a
Reusableobject.
-
std::unique_ptr<Reusable> borrowObject()