ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
node_pool Struct Reference

Memory pool for packet nodes to reduce malloc/free overhead. More...

#include <include/ascii-chat/network/packet/queue.h>

Data Fields

atomic_ptr_t free_list
 Stack of free nodes (LIFO for cache locality) - atomic for lock-free access.
 
packet_node_t * nodes
 Pre-allocated array of all nodes.
 
size_t pool_size
 Total number of nodes in pool.
 
atomic_t used_count
 Number of nodes currently in use - atomic for lock-free tracking.
 

Detailed Description

Memory pool for packet nodes to reduce malloc/free overhead.

Pre-allocates a fixed-size array of packet nodes and maintains a lock-free free list using atomic compare-and-swap operations. This eliminates per-packet malloc/free calls and avoids lock contention for high-frequency packet queue operations.

Note
Pool operations are thread-safe via lock-free atomics (no mutexes).
If pool is exhausted, operations fall back to malloc/free.

Definition at line 167 of file queue.h.


The documentation for this struct was generated from the following file: