liveBook · Manning

Spsc bounded queue

As explained in Latency

An SPSC bounded queue is a fixed-capacity FIFO data structure with exactly one producer and one consumer.

An SPSC bounded queue is a fixed-capacity FIFO structure with exactly one producer and one consumer. It tracks monotonically increasing front and back indexes, wraps array access with modulo arithmetic, and reports full or empty states. section 8.6

The concurrent version replaces ordinary indexes with atomic counters. The producer writes an item before releasing back; the consumer reads after acquiring back, then releases front. Relaxed operations serve each thread’s own counter, while acquire and release operations publish data safely without mutual exclusion. section 8.6

Benchmarking the queue

A Rust benchmark runs a producer and consumer against a 128-element queue. The measured pop time is approximately 72.8 ns, compared with approximately 1.11 µs for the non-atomic queue benchmark.

How Latency covers it

How deep it goes
Descends from FIFO mechanics through atomic ordering and circular indexing to runnable Rust code and benchmark measurements.
Examples
Uses Rust push and pop implementations plus a concurrent 128-element benchmark.
What it assumes
Assumes basic programming and develops practical reasoning about atomics and memory barriers through implementation.
What you can do after
Build it from scratch in Rust and measure producer-consumer queue performance.
How it connects
Connects FIFO queues with atomics, memory barriers, acquire-release ordering, and wait-free synchronization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.