ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
ringbuffer_t Struct Reference

Lock-free ring buffer structure. More...

#include <lib/ringbuffer.h>

Data Fields

char * buffer
 The actual buffer memory.
 
size_t element_size
 Size of each element in bytes.
 
size_t capacity
 Number of elements that can be stored.
 
_Atomic size_t head
 Write position (producer) - atomic for lock-free operations.
 
_Atomic size_t tail
 Read position (consumer) - atomic for lock-free operations.
 
_Atomic size_t size
 Current number of elements - atomic for fast size checks.
 
bool is_power_of_two
 Whether capacity is power of 2 (enables bit masking optimization)
 
size_t capacity_mask
 Mask for fast modulo when capacity is power of 2.
 

Detailed Description

Lock-free ring buffer structure.

Implements a lock-free circular buffer using atomic operations for thread-safe producer-consumer data transfer without locking overhead.

Definition at line 95 of file ringbuffer.h.

Field Documentation

◆ buffer

char* ringbuffer_t::buffer

The actual buffer memory.

Definition at line 97 of file ringbuffer.h.

Referenced by framebuffer_clear(), ringbuffer_create(), ringbuffer_destroy(), ringbuffer_peek(), ringbuffer_read(), and ringbuffer_write().

◆ capacity

size_t ringbuffer_t::capacity

Number of elements that can be stored.

Definition at line 101 of file ringbuffer.h.

Referenced by framebuffer_clear(), framebuffer_write_frame(), ringbuffer_create(), ringbuffer_is_full(), and ringbuffer_write().

◆ capacity_mask

size_t ringbuffer_t::capacity_mask

Mask for fast modulo when capacity is power of 2.

Definition at line 111 of file ringbuffer.h.

Referenced by ringbuffer_create(), ringbuffer_read(), and ringbuffer_write().

◆ element_size

size_t ringbuffer_t::element_size

Size of each element in bytes.

Definition at line 99 of file ringbuffer.h.

Referenced by framebuffer_clear(), ringbuffer_create(), ringbuffer_peek(), ringbuffer_read(), and ringbuffer_write().

◆ head

_Atomic size_t ringbuffer_t::head

Write position (producer) - atomic for lock-free operations.

Definition at line 103 of file ringbuffer.h.

Referenced by ringbuffer_clear(), ringbuffer_create(), and ringbuffer_write().

◆ is_power_of_two

bool ringbuffer_t::is_power_of_two

Whether capacity is power of 2 (enables bit masking optimization)

Definition at line 109 of file ringbuffer.h.

Referenced by ringbuffer_create().

◆ size

_Atomic size_t ringbuffer_t::size

Current number of elements - atomic for fast size checks.

Definition at line 107 of file ringbuffer.h.

Referenced by ringbuffer_clear(), ringbuffer_create(), ringbuffer_peek(), ringbuffer_read(), ringbuffer_size(), and ringbuffer_write().

◆ tail

_Atomic size_t ringbuffer_t::tail

Read position (consumer) - atomic for lock-free operations.

Definition at line 105 of file ringbuffer.h.

Referenced by ringbuffer_clear(), ringbuffer_create(), ringbuffer_peek(), and ringbuffer_read().


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