|
nfx-stringbuilderpool 1.0.0
High-performance C++20 library for zero-allocation string building with thread-safe pooling
|
Thread-safe memory pool for high-performance StringBuilder instances with optimized allocation strategy. More...
#include <nfx/string/StringBuilderPool.h>
Classes | |
| struct | PoolStatistics |
| Pool performance statistics for external access. More... | |
Static Public Member Functions | |
| static StringBuilderLease | lease () |
| Creates a new StringBuilder lease with an optimally sourced memory buffer. | |
| static PoolStatistics | stats () noexcept |
| Gets current pool statistics. | |
| static void | resetStats () noexcept |
| Resets pool statistics. | |
| static size_t | clear () |
| Clears all buffers from the pool and returns the count of cleared buffers. | |
| static size_t | size () noexcept |
| Gets current number of buffers stored in the pool. | |
Thread-safe memory pool for high-performance StringBuilder instances with optimized allocation strategy.
Implements a three-tier pooling system for DynamicStringBuffer instances to minimize allocation overhead in high-frequency string building scenarios. Features thread-local caching, shared cross-thread pooling, and comprehensive statistics tracking. Designed as a singleton with static factory methods for global access.
Definition at line 857 of file StringBuilderPool.h.
|
static |
Clears all buffers from the pool and returns the count of cleared buffers.
|
static |
Creates a new StringBuilder lease with an optimally sourced memory buffer.
This is the primary factory method for obtaining StringBuilder instances. The buffer is sourced using a three-tier optimization strategy:
The returned lease automatically returns the buffer to the pool when destroyed, ensuring optimal memory reuse and preventing leaks.
This method is thread-safe and optimized for high-frequency usage patterns. Buffers are automatically cleared before reuse and size-limited to prevent bloat.
|
staticnoexcept |
Gets current number of buffers stored in the pool.
|
staticnoexcept |
Gets current pool statistics.