46 class buffer_pool :
public std::enable_shared_from_this<buffer_pool>
54 explicit buffer_pool(
size_t pool_size = 32,
size_t default_capacity = 8192);
69 auto acquire(
size_t min_capacity = 0) -> std::shared_ptr<std::vector<uint8_t>>;
75 auto get_stats()
const -> std::pair<size_t, size_t>;
89 auto release(std::vector<uint8_t>* buffer) -> void;
Thread-safe memory pool for reusable byte buffers.
buffer_pool(size_t pool_size=32, size_t default_capacity=8192)
Constructs a buffer pool.
auto get_stats() const -> std::pair< size_t, size_t >
Gets current pool statistics.
auto clear() -> void
Clears the pool and releases all cached buffers.
std::unique_ptr< impl > pimpl_
~buffer_pool() noexcept
Destructor.
auto release(std::vector< uint8_t > *buffer) -> void
Returns a buffer to the pool.
auto acquire(size_t min_capacity=0) -> std::shared_ptr< std::vector< uint8_t > >
Acquires a buffer from the pool.
Utility components for network_system.