|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
📬 Thread-safe per-client packet queues More...
Files | |
| file | packet_queue.c |
| 📬 Lock-free packet queue with per-client isolation and memory pooling | |
| file | packet_queue.h |
| 📬 Thread-safe packet queue system for per-client send threads | |
Data Structures | |
| struct | queued_packet_t |
| Single packet ready to send (header already in network byte order) More... | |
| struct | packet_node |
| Node in the packet queue linked list. More... | |
| struct | node_pool |
| Memory pool for packet nodes to reduce malloc/free overhead. More... | |
| struct | packet_queue_t |
| Thread-safe packet queue for producer-consumer communication. More... | |
Typedefs | |
| typedef struct packet_node | packet_node_t |
| Forward declaration for packet queue node. | |
| typedef struct node_pool | node_pool_t |
| Memory pool for packet nodes to reduce malloc/free overhead. | |
Functions | |
| packet_node::_Atomic (packet_node_t *) next | |
| Pointer to next node in linked list (NULL for tail) - atomic for lock-free operations. | |
| packet_queue_t::_Atomic (packet_node_t *) head | |
| Front of queue (dequeue from here) - atomic for lock-free access. | |
Variables | |
| packet_header_t | queued_packet_t::header |
| Complete packet header (already in network byte order) | |
| void * | queued_packet_t::data |
| Packet payload data (can be NULL for header-only packets) | |
| size_t | queued_packet_t::data_len |
| Length of payload data in bytes. | |
| bool | queued_packet_t::owns_data |
| If true, free data when packet is freed. | |
| buffer_pool_t * | queued_packet_t::buffer_pool |
| Pool that allocated the data (NULL if malloc'd) | |
| queued_packet_t | packet_node::packet |
| The queued packet data. | |
| packet_node_t * | node_pool::free_list |
| Stack of free nodes (LIFO for cache locality) | |
| packet_node_t * | node_pool::nodes |
| Pre-allocated array of all nodes. | |
| size_t | node_pool::pool_size |
| Total number of nodes in pool. | |
| size_t | node_pool::used_count |
| Number of nodes currently in use. | |
| mutex_t | node_pool::pool_mutex |
| Mutex protecting free list access. | |
| _Atomic size_t | packet_queue_t::count |
| Number of packets currently in queue - atomic for lock-free access. | |
| size_t | packet_queue_t::max_size |
| Maximum queue size (0 = unlimited) | |
| _Atomic size_t | packet_queue_t::bytes_queued |
| Total bytes of data queued (for monitoring) - atomic for lock-free access. | |
| node_pool_t * | packet_queue_t::node_pool |
| Optional memory pool for nodes (NULL = use malloc/free) | |
| buffer_pool_t * | packet_queue_t::buffer_pool |
| Optional memory pool for data buffers (NULL = use malloc/free) | |
| _Atomic uint64_t | packet_queue_t::packets_enqueued |
| Total packets enqueued (statistics) - atomic for lock-free access. | |
| _Atomic uint64_t | packet_queue_t::packets_dequeued |
| Total packets dequeued (statistics) - atomic for lock-free access. | |
| _Atomic uint64_t | packet_queue_t::packets_dropped |
| Total packets dropped due to queue full (statistics) - atomic for lock-free access. | |
| _Atomic bool | packet_queue_t::shutdown |
| Shutdown flag (true = dequeue returns NULL) - atomic for lock-free access. | |
Node Pool Functions | |
| node_pool_t * | node_pool_create (size_t pool_size) |
| Create a memory pool for packet queue nodes. | |
| void | node_pool_destroy (node_pool_t *pool) |
| Destroy a node pool and free all memory. | |
| packet_node_t * | node_pool_get (node_pool_t *pool) |
| Get a free node from the pool. | |
| void | node_pool_put (node_pool_t *pool, packet_node_t *node) |
| Return a node to the pool. | |
Queue Management Functions | |
| packet_queue_t * | packet_queue_create (size_t max_size) |
| Create a new packet queue. | |
| packet_queue_t * | packet_queue_create_with_pool (size_t max_size, size_t pool_size) |
| Create a packet queue with node pool. | |
| packet_queue_t * | packet_queue_create_with_pools (size_t max_size, size_t node_pool_size, bool use_buffer_pool) |
| Create a packet queue with both node and buffer pools. | |
| void | packet_queue_destroy (packet_queue_t *queue) |
| Destroy a packet queue and free all resources. | |
Queue Operations | |
| int | packet_queue_enqueue (packet_queue_t *queue, packet_type_t type, const void *data, size_t data_len, uint32_t client_id, bool copy_data) |
| Enqueue a packet into the queue. | |
| int | packet_queue_enqueue_packet (packet_queue_t *queue, const queued_packet_t *packet) |
| Enqueue a pre-built packet (for special cases like compressed frames) | |
| queued_packet_t * | packet_queue_dequeue (packet_queue_t *queue) |
| Dequeue a packet from the queue (non-blocking) | |
| queued_packet_t * | packet_queue_try_dequeue (packet_queue_t *queue) |
| Try to dequeue a packet without blocking. | |
| void | packet_queue_free_packet (queued_packet_t *packet) |
| Free a dequeued packet. | |
Queue Status Functions | |
| size_t | packet_queue_size (packet_queue_t *queue) |
| Get current number of packets in queue. | |
| bool | packet_queue_is_empty (packet_queue_t *queue) |
| Check if queue is empty. | |
| bool | packet_queue_is_full (packet_queue_t *queue) |
| Check if queue is full. | |
Queue Control Functions | |
| void | packet_queue_shutdown (packet_queue_t *queue) |
| Signal queue shutdown (causes dequeue to return NULL) | |
| void | packet_queue_clear (packet_queue_t *queue) |
| Clear all packets from queue. | |
Statistics Functions | |
| void | packet_queue_get_stats (packet_queue_t *queue, uint64_t *enqueued, uint64_t *dequeued, uint64_t *dropped) |
| Get queue statistics. | |
| bool | packet_queue_validate_packet (const queued_packet_t *packet) |
| Validate packet integrity. | |
📬 Thread-safe per-client packet queues
This module implements a high-performance thread-safe queue for network packets, enabling producer threads (audio mixer, video broadcast) to enqueue packets while consumer threads (per-client send threads) dequeue and transmit them. This design eliminates shared bottlenecks and enables linear scaling across multiple clients.
PRODUCER-CONSUMER MODEL:
QUEUE DESIGN:
MEMORY MANAGEMENT:
SYNCHRONIZATION PRIMITIVES:
LOCK-FREE PATTERN:
Welcome! Let's talk about packet queues—the unsung heroes that keep ascii-chat's network communication smooth and organized.
Imagine you're at a busy restaurant. Orders are coming in from multiple tables, and the kitchen needs to process them one at a time. You don't want orders getting mixed up or lost, right? That's exactly what packet queues do for network data—they line up incoming packets so each client's data gets processed in order, without chaos.
Each client connected to the server gets their own dedicated packet queue. When packets arrive over the network, they get placed in the appropriate client's queue. Then, a separate thread can process packets at its own pace without blocking the network thread. It's like having a separate order ticket for each table—clean, organized, and efficient.
Implementation: lib/packet_queue.c/h
Queues can either copy packet data or reference it:
Deep copy mode (owns_data = true):
Reference mode (owns_data = false):
Buffer Pool Integration:
Network Integration:
Throughput:
Scalability:
Mutex Protection:
Concurrent Access:
| typedef struct node_pool node_pool_t |
#include <packet_queue.h>
Memory pool for packet nodes to reduce malloc/free overhead.
Pre-allocates a fixed-size array of packet nodes and maintains a free list. This eliminates per-packet malloc/free calls, significantly improving performance for high-frequency packet queue operations.
| typedef struct packet_node packet_node_t |
#include <packet_queue.h>
Forward declaration for packet queue node.
Definition at line 137 of file packet_queue.h.
| packet_queue_t::_Atomic | ( | packet_node_t * | ) |
#include <packet_queue.h>
Front of queue (dequeue from here) - atomic for lock-free access.
| packet_node::_Atomic | ( | packet_node_t * | ) |
#include <packet_queue.h>
Pointer to next node in linked list (NULL for tail) - atomic for lock-free operations.
| node_pool_t * node_pool_create | ( | size_t | pool_size | ) |
#include <packet_queue.h>
Create a memory pool for packet queue nodes.
| pool_size | Number of nodes to pre-allocate |
Pre-allocates a fixed-size array of packet nodes to eliminate per-packet malloc/free overhead. All nodes are initialized and added to the free list.
Definition at line 25 of file packet_queue.c.
References ERROR_PLATFORM_INIT, node_pool::free_list, mutex_init(), node_pool_destroy(), node_pool::nodes, node_pool::pool_mutex, node_pool::pool_size, SAFE_MALLOC, SET_ERRNO, and node_pool::used_count.
Referenced by packet_queue_create_with_pools().
| void node_pool_destroy | ( | node_pool_t * | pool | ) |
#include <packet_queue.h>
Destroy a node pool and free all memory.
| pool | Node pool to destroy (can be NULL) |
Frees all pre-allocated nodes and the pool structure itself.
Definition at line 55 of file packet_queue.c.
References mutex_destroy(), node_pool::nodes, node_pool::pool_mutex, and SAFE_FREE.
Referenced by node_pool_create(), and packet_queue_destroy().
| packet_node_t * node_pool_get | ( | node_pool_t * | pool | ) |
#include <packet_queue.h>
Get a free node from the pool.
| pool | Node pool |
Removes a node from the free list. If pool is exhausted, returns NULL (caller should fall back to malloc).
Definition at line 65 of file packet_queue.c.
References node_pool::free_list, log_debug, mutex_lock, mutex_unlock, node_pool::pool_mutex, node_pool::pool_size, SAFE_MALLOC, and node_pool::used_count.
Referenced by packet_queue_enqueue(), and packet_queue_enqueue_packet().
| void node_pool_put | ( | node_pool_t * | pool, |
| packet_node_t * | node | ||
| ) |
#include <packet_queue.h>
Return a node to the pool.
| pool | Node pool |
| node | Node to return (must have been allocated from this pool) |
Returns a node to the free list for reuse. Node should not be in use by any queue when returned.
Definition at line 94 of file packet_queue.c.
References node_pool::free_list, mutex_lock, mutex_unlock, node_pool::nodes, node_pool::pool_mutex, node_pool::pool_size, SAFE_FREE, and node_pool::used_count.
Referenced by packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_try_dequeue().
| void packet_queue_clear | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Clear all packets from queue.
| queue | Packet queue |
Removes and frees all packets currently in the queue. Useful for cleanup before queue destruction or when resetting queue state.
Definition at line 606 of file packet_queue.c.
References packet_queue_free_packet(), and packet_queue_try_dequeue().
Referenced by packet_queue_destroy().
| packet_queue_t * packet_queue_create | ( | size_t | max_size | ) |
#include <packet_queue.h>
Create a new packet queue.
| max_size | Maximum queue size (0 = unlimited) |
Creates a packet queue without memory pools. Queue will use malloc/free for all node and data allocations.
Definition at line 128 of file packet_queue.c.
References packet_queue_create_with_pool().
| packet_queue_t * packet_queue_create_with_pool | ( | size_t | max_size, |
| size_t | pool_size | ||
| ) |
#include <packet_queue.h>
Create a packet queue with node pool.
| max_size | Maximum queue size (0 = unlimited) |
| pool_size | Number of nodes to pre-allocate in pool |
Creates a packet queue with optional node pool to reduce malloc overhead. Queue will still use malloc/free for packet data allocations.
Definition at line 132 of file packet_queue.c.
References packet_queue_create_with_pools().
Referenced by packet_queue_create().
| packet_queue_t * packet_queue_create_with_pools | ( | size_t | max_size, |
| size_t | node_pool_size, | ||
| bool | use_buffer_pool | ||
| ) |
#include <packet_queue.h>
Create a packet queue with both node and buffer pools.
| max_size | Maximum queue size (0 = unlimited) |
| node_pool_size | Number of nodes to pre-allocate |
| use_buffer_pool | If true, use global buffer pool for packet data |
Creates a high-performance packet queue with both node and buffer pools enabled. This enables zero-allocation operation when pools are configured.
Definition at line 136 of file packet_queue.c.
References packet_queue_t::buffer_pool, buffer_pool_create(), packet_queue_t::bytes_queued, packet_queue_t::count, packet_queue_t::max_size, packet_queue_t::node_pool, node_pool_create(), packet_queue_t::packets_dequeued, packet_queue_t::packets_dropped, packet_queue_t::packets_enqueued, SAFE_MALLOC, and packet_queue_t::shutdown.
Referenced by packet_queue_create_with_pool().
| queued_packet_t * packet_queue_dequeue | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Dequeue a packet from the queue (non-blocking)
| queue | Packet queue |
Removes and returns the packet at the head of the queue. Returns NULL immediately if queue is empty or shutdown (non-blocking operation).
Definition at line 459 of file packet_queue.c.
References packet_queue_try_dequeue().
| void packet_queue_destroy | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Destroy a packet queue and free all resources.
| queue | Queue to destroy (can be NULL) |
Destroys the queue and all associated resources (node pool, etc.).
Definition at line 161 of file packet_queue.c.
References packet_queue_t::buffer_pool, buffer_pool_destroy(), buffer_pool_log_stats(), packet_queue_t::node_pool, node_pool_destroy(), packet_queue_clear(), packet_queue_shutdown(), and SAFE_FREE.
Referenced by cleanup_client_packet_queues().
| int packet_queue_enqueue | ( | packet_queue_t * | queue, |
| packet_type_t | type, | ||
| const void * | data, | ||
| size_t | data_len, | ||
| uint32_t | client_id, | ||
| bool | copy_data | ||
| ) |
#include <packet_queue.h>
Enqueue a packet into the queue.
| queue | Packet queue |
| type | Packet type (from packet_types.h) |
| data | Packet payload data (can be NULL) |
| data_len | Length of payload data in bytes |
| client_id | Client ID for packet header |
| copy_data | If true, copy data into pool/malloc buffer; if false, use data pointer directly |
Enqueues a new packet at the tail of the queue. If copy_data is true, packet data is copied into a buffer (from pool if available, otherwise malloc). If copy_data is false, the data pointer is used directly (caller must ensure data remains valid until packet is dequeued and freed).
Definition at line 185 of file packet_queue.c.
References asciichat_crc32, queued_packet_t::buffer_pool, packet_queue_t::buffer_pool, buffer_pool_alloc(), buffer_pool_free(), buffer_pool_get_global(), packet_queue_t::bytes_queued, packet_header_t::client_id, packet_queue_t::count, packet_header_t::crc32, queued_packet_t::data, queued_packet_t::data_len, ERROR_MEMORY, queued_packet_t::header, HOST_TO_NET_U16, HOST_TO_NET_U32, packet_header_t::length, log_debug_every, LOG_RATE_FAST, packet_header_t::magic, packet_queue_t::max_size, packet_queue_t::node_pool, node_pool_get(), node_pool_put(), queued_packet_t::owns_data, packet_node::packet, PACKET_MAGIC, packet_queue_t::packets_dropped, packet_queue_t::packets_enqueued, SAFE_MEMCPY, SET_ERRNO, packet_queue_t::shutdown, and packet_header_t::type.
Referenced by client_audio_render_thread(), and queue_audio_for_client().
| int packet_queue_enqueue_packet | ( | packet_queue_t * | queue, |
| const queued_packet_t * | packet | ||
| ) |
#include <packet_queue.h>
Enqueue a pre-built packet (for special cases like compressed frames)
| queue | Packet queue |
| packet | Pre-built packet structure |
Enqueues a packet that has already been built (header, data, etc.). Useful for special cases like compressed frames where packet construction is done outside the normal enqueue path.
Definition at line 324 of file packet_queue.c.
References queued_packet_t::buffer_pool, packet_queue_t::buffer_pool, buffer_pool_alloc(), buffer_pool_free(), buffer_pool_get_global(), packet_queue_t::bytes_queued, packet_queue_t::count, queued_packet_t::data, queued_packet_t::data_len, ERROR_INVALID_PARAM, ERROR_MEMORY, packet_queue_t::max_size, packet_queue_t::node_pool, node_pool_get(), node_pool_put(), queued_packet_t::owns_data, packet_node::packet, packet_queue_validate_packet(), packet_queue_t::packets_dropped, packet_queue_t::packets_enqueued, SAFE_MEMCPY, SET_ERRNO, and packet_queue_t::shutdown.
| void packet_queue_free_packet | ( | queued_packet_t * | packet | ) |
#include <packet_queue.h>
Free a dequeued packet.
| packet | Packet to free (can be NULL) |
Properly frees packet memory, returning data to buffer pool if applicable, or calling free() if allocated with malloc. Also frees packet structure itself.
Definition at line 548 of file packet_queue.c.
References queued_packet_t::buffer_pool, buffer_pool_free(), queued_packet_t::data, queued_packet_t::data_len, queued_packet_t::header, HOST_TO_NET_U32, log_warn, packet_header_t::magic, NET_TO_HOST_U32, queued_packet_t::owns_data, PACKET_MAGIC, and SAFE_FREE.
Referenced by client_send_thread_func(), and packet_queue_clear().
| void packet_queue_get_stats | ( | packet_queue_t * | queue, |
| uint64_t * | enqueued, | ||
| uint64_t * | dequeued, | ||
| uint64_t * | dropped | ||
| ) |
#include <packet_queue.h>
Get queue statistics.
| queue | Packet queue |
| enqueued | Output: Total packets enqueued |
| dequeued | Output: Total packets dequeued |
| dropped | Output: Total packets dropped (due to queue full) |
Retrieves cumulative statistics for the queue. Useful for performance monitoring and debugging.
Definition at line 617 of file packet_queue.c.
References packet_queue_t::packets_dequeued, packet_queue_t::packets_dropped, and packet_queue_t::packets_enqueued.
Referenced by stats_logger_thread().
| bool packet_queue_is_empty | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Check if queue is empty.
| queue | Packet queue |
Returns true if queue contains no packets. Snapshot value may change immediately after return due to concurrent operations.
Definition at line 583 of file packet_queue.c.
References packet_queue_size().
| bool packet_queue_is_full | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Check if queue is full.
| queue | Packet queue |
Returns true if queue has reached its maximum size. Unlimited queues (max_size == 0) never return true from this function.
Definition at line 587 of file packet_queue.c.
References packet_queue_t::count, and packet_queue_t::max_size.
| void packet_queue_shutdown | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Signal queue shutdown (causes dequeue to return NULL)
| queue | Packet queue |
Sets the shutdown flag, causing all dequeue operations to return NULL. This allows consumer threads to exit gracefully without blocking forever.
Definition at line 596 of file packet_queue.c.
References ERROR_INVALID_PARAM, SET_ERRNO, and packet_queue_t::shutdown.
Referenced by disconnect_client_for_bad_data(), and packet_queue_destroy().
| size_t packet_queue_size | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Get current number of packets in queue.
| queue | Packet queue |
Returns the current queue size (count field). This is a snapshot and may change immediately after return due to concurrent enqueue/dequeue operations.
Definition at line 575 of file packet_queue.c.
References packet_queue_t::count.
Referenced by client_audio_render_thread(), and packet_queue_is_empty().
| queued_packet_t * packet_queue_try_dequeue | ( | packet_queue_t * | queue | ) |
#include <packet_queue.h>
Try to dequeue a packet without blocking.
| queue | Packet queue |
Non-blocking version of packet_queue_dequeue(). Returns immediately with NULL if queue is empty or shutdown, otherwise returns next packet.
Definition at line 464 of file packet_queue.c.
References asciichat_crc32, queued_packet_t::buffer_pool, buffer_pool_free(), packet_queue_t::bytes_queued, packet_queue_t::count, packet_header_t::crc32, queued_packet_t::data, queued_packet_t::data_len, ERROR_BUFFER, queued_packet_t::header, packet_header_t::magic, NET_TO_HOST_U16, NET_TO_HOST_U32, packet_queue_t::node_pool, node_pool_put(), queued_packet_t::owns_data, packet_node::packet, PACKET_MAGIC, packet_queue_t::packets_dequeued, SAFE_MALLOC, SAFE_MEMCPY, SET_ERRNO, packet_queue_t::shutdown, and packet_header_t::type.
Referenced by client_send_thread_func(), packet_queue_clear(), and packet_queue_dequeue().
| bool packet_queue_validate_packet | ( | const queued_packet_t * | packet | ) |
#include <packet_queue.h>
Validate packet integrity.
| packet | Packet to validate |
Validates packet structure and header integrity. Useful for debugging and detecting memory corruption.
Definition at line 630 of file packet_queue.c.
References asciichat_crc32, packet_header_t::crc32, queued_packet_t::data, queued_packet_t::data_len, ERROR_BUFFER, queued_packet_t::header, packet_header_t::length, packet_header_t::magic, NET_TO_HOST_U16, NET_TO_HOST_U32, PACKET_MAGIC, PACKET_TYPE_AUDIO_BATCH, SET_ERRNO, and packet_header_t::type.
Referenced by packet_queue_enqueue_packet().
| buffer_pool_t* queued_packet_t::buffer_pool |
Pool that allocated the data (NULL if malloc'd)
Definition at line 130 of file packet_queue.h.
Referenced by packet_queue_enqueue(), packet_queue_enqueue_packet(), packet_queue_free_packet(), and packet_queue_try_dequeue().
| buffer_pool_t* packet_queue_t::buffer_pool |
Optional memory pool for data buffers (NULL = use malloc/free)
Definition at line 228 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_destroy(), packet_queue_enqueue(), and packet_queue_enqueue_packet().
| _Atomic size_t packet_queue_t::bytes_queued |
Total bytes of data queued (for monitoring) - atomic for lock-free access.
Definition at line 223 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_try_dequeue().
| _Atomic size_t packet_queue_t::count |
Number of packets currently in queue - atomic for lock-free access.
Definition at line 219 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_enqueue(), packet_queue_enqueue_packet(), packet_queue_is_full(), packet_queue_size(), and packet_queue_try_dequeue().
| void* queued_packet_t::data |
Packet payload data (can be NULL for header-only packets)
Definition at line 124 of file packet_queue.h.
Referenced by client_send_thread_func(), packet_queue_enqueue(), packet_queue_enqueue_packet(), packet_queue_free_packet(), packet_queue_try_dequeue(), and packet_queue_validate_packet().
| size_t queued_packet_t::data_len |
Length of payload data in bytes.
Definition at line 126 of file packet_queue.h.
Referenced by client_send_thread_func(), packet_queue_enqueue(), packet_queue_enqueue_packet(), packet_queue_free_packet(), packet_queue_try_dequeue(), and packet_queue_validate_packet().
| packet_node_t* node_pool::free_list |
Stack of free nodes (LIFO for cache locality)
Definition at line 169 of file packet_queue.h.
Referenced by node_pool_create(), node_pool_get(), and node_pool_put().
| packet_header_t queued_packet_t::header |
Complete packet header (already in network byte order)
Definition at line 122 of file packet_queue.h.
Referenced by packet_queue_enqueue(), packet_queue_free_packet(), packet_queue_try_dequeue(), and packet_queue_validate_packet().
| size_t packet_queue_t::max_size |
Maximum queue size (0 = unlimited)
Definition at line 221 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_is_full().
| node_pool_t* packet_queue_t::node_pool |
Optional memory pool for nodes (NULL = use malloc/free)
Definition at line 226 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_destroy(), packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_try_dequeue().
| packet_node_t* node_pool::nodes |
Pre-allocated array of all nodes.
Definition at line 171 of file packet_queue.h.
Referenced by node_pool_create(), node_pool_destroy(), and node_pool_put().
| bool queued_packet_t::owns_data |
If true, free data when packet is freed.
Definition at line 128 of file packet_queue.h.
Referenced by packet_queue_enqueue(), packet_queue_enqueue_packet(), packet_queue_free_packet(), and packet_queue_try_dequeue().
| queued_packet_t packet_node::packet |
The queued packet data.
Definition at line 149 of file packet_queue.h.
Referenced by packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_try_dequeue().
Total packets dequeued (statistics) - atomic for lock-free access.
Definition at line 233 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_get_stats(), and packet_queue_try_dequeue().
Total packets dropped due to queue full (statistics) - atomic for lock-free access.
Definition at line 235 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_get_stats().
Total packets enqueued (statistics) - atomic for lock-free access.
Definition at line 231 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_enqueue(), packet_queue_enqueue_packet(), and packet_queue_get_stats().
| mutex_t node_pool::pool_mutex |
Mutex protecting free list access.
Definition at line 177 of file packet_queue.h.
Referenced by node_pool_create(), node_pool_destroy(), node_pool_get(), and node_pool_put().
| size_t node_pool::pool_size |
Total number of nodes in pool.
Definition at line 173 of file packet_queue.h.
Referenced by node_pool_create(), node_pool_get(), and node_pool_put().
Shutdown flag (true = dequeue returns NULL) - atomic for lock-free access.
Definition at line 238 of file packet_queue.h.
Referenced by packet_queue_create_with_pools(), packet_queue_enqueue(), packet_queue_enqueue_packet(), packet_queue_shutdown(), and packet_queue_try_dequeue().
| size_t node_pool::used_count |
Number of nodes currently in use.
Definition at line 175 of file packet_queue.h.
Referenced by node_pool_create(), node_pool_get(), and node_pool_put().