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

Lock-free ring buffer structure. More...

#include <include/ascii-chat/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_t head
 Write position (producer) - atomic for lock-free operations.
 
atomic_t tail
 Read position (consumer) - atomic for lock-free operations.
 
atomic_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 88 of file ringbuffer.h.

Field Documentation

◆ buffer

char* ringbuffer_t::buffer

The actual buffer memory.

Definition at line 90 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 94 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 104 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 92 of file ringbuffer.h.

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

◆ head

atomic_t ringbuffer_t::head

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

Definition at line 96 of file ringbuffer.h.

Referenced by ringbuffer_clear(), 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 102 of file ringbuffer.h.

Referenced by ringbuffer_create().

◆ size

atomic_t ringbuffer_t::size

Current number of elements - atomic for fast size checks.

Definition at line 100 of file ringbuffer.h.

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

◆ tail

atomic_t ringbuffer_t::tail

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

Definition at line 98 of file ringbuffer.h.

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


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