|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
🗃️ Lock-Free Unified Memory Buffer Pool with Lazy Allocation More...
Go to the source code of this file.
Data Structures | |
| struct | buffer_node |
| Node header embedded before user data. More... | |
| struct | buffer_pool |
| Unified buffer pool with lock-free fast path. More... | |
Macros | |
| #define | BUFFER_POOL_MAX_BYTES (337 * 1024 * 1024) |
| Maximum total bytes the pool can hold (337 MB) | |
| #define | BUFFER_POOL_SHRINK_DELAY_MS 5000 |
| Time in milliseconds before unused buffers are freed (5 seconds) | |
| #define | BUFFER_POOL_MIN_SIZE 64 |
| Minimum buffer size to pool (smaller allocations use malloc directly) | |
| #define | BUFFER_POOL_MAX_SINGLE_SIZE (4 * 1024 * 1024) |
| Maximum single buffer size to pool (larger allocations use malloc directly) | |
| #define | BUFFER_POOL_MAGIC 0xBF00B001U |
| Magic value to identify pooled buffers. | |
| #define | BUFFER_POOL_MAGIC_FALLBACK 0xBF00FA11U |
| Magic value for malloc fallback buffers (not in pool) | |
| #define | POOL_ALLOC(size) buffer_pool_alloc(NULL, (size)) |
| #define | POOL_FREE(data, size) buffer_pool_free(NULL, (data), (size)) |
Typedefs | |
| typedef struct buffer_node | buffer_node_t |
| Node header embedded before user data. | |
| typedef struct buffer_pool | buffer_pool_t |
| Unified buffer pool with lock-free fast path. | |
Functions | |
| buffer_pool_t * | buffer_pool_create (size_t max_bytes, uint64_t shrink_delay_ms) |
| Create a new buffer pool. | |
| void | buffer_pool_destroy (buffer_pool_t *pool) |
| Destroy a buffer pool and free all memory. | |
| void * | buffer_pool_alloc (buffer_pool_t *pool, size_t size) |
| Allocate a buffer from the pool (lock-free fast path) | |
| void | buffer_pool_free (buffer_pool_t *pool, void *data, size_t size) |
| Free a buffer back to the pool (lock-free) | |
| void | buffer_pool_shrink (buffer_pool_t *pool) |
| Force shrink the pool (free old unused buffers) | |
| void | buffer_pool_get_stats (buffer_pool_t *pool, size_t *current_bytes, size_t *used_bytes, size_t *free_bytes) |
| Get pool statistics (atomic reads) | |
| void | buffer_pool_log_stats (buffer_pool_t *pool, const char *name) |
| Log pool statistics. | |
| void | buffer_pool_init_global (void) |
| void | buffer_pool_cleanup_global (void) |
| buffer_pool_t * | buffer_pool_get_global (void) |
🗃️ Lock-Free Unified Memory Buffer Pool with Lazy Allocation
Definition in file buffer_pool.h.