|
asynchrony 0.0.0
Add asynchrony to your C++ applications using standard C++20
|
Implements a resource pool that stores objects of type T. Said objects can be shared_ptr or unique_ptr Client "acquire" and "release" T from this pool. The capacity of this pool should be kept at the same value as std::thread::hardware_concurrency(). More...
#include </opt/azure-agent/_work/14/s/include/siddiqsoft/resource_pool.hpp>
Public Member Functions | |
| resource_pool (resource_pool &)=delete | |
| resource_pool (resource_pool &&src)=default | |
| resource_pool & | operator= (resource_pool &)=delete |
| resource_pool & | operator= (resource_pool &&src)=default |
| void | clear () |
| Clear all items from the pool FIX: Removed unnecessary empty check - clear() is safe on empty deque. | |
| auto | size () |
| Get the current size of the pool FIX: Removed unnecessary empty check - return size unconditionally This prevents TOCTOU (Time-of-Check-Time-of-Use) race condition. | |
| T | checkout () |
| void | checkin (T &&rsrc) |
| Insert a new element or return a borrowed element. | |
Implements a resource pool that stores objects of type T. Said objects can be shared_ptr or unique_ptr Client "acquire" and "release" T from this pool. The capacity of this pool should be kept at the same value as std::thread::hardware_concurrency().
| T | The storage element type. Maybe shared_ptr or unique_ptr The only requirement is that the underlying object is move-constructible! |
Definition at line 60 of file resource_pool.hpp.
|
inline |
Definition at line 73 of file resource_pool.hpp.
|
inline |
Insert a new element or return a borrowed element.
| rsrc | R-Value for the item to return to the pool (previously checkout'd or create a new one!) |
Definition at line 111 of file resource_pool.hpp.
|
inlinenodiscard |
Definition at line 95 of file resource_pool.hpp.
|
inline |
Clear all items from the pool FIX: Removed unnecessary empty check - clear() is safe on empty deque.
Definition at line 80 of file resource_pool.hpp.
|
inline |
Get the current size of the pool FIX: Removed unnecessary empty check - return size unconditionally This prevents TOCTOU (Time-of-Check-Time-of-Use) race condition.
Definition at line 89 of file resource_pool.hpp.