liveBook · Manning

Bounded queue

As explained in Rust in Action: Systems programming concepts and techniques

A bounded queue is a queue with a fixed capacity that can make producers wait when no space is available.

A bounded queue gives a channel a fixed capacity. When the queue fills, producers wait for space instead of allowing messages to accumulate without limit. This applies back pressure, helping prevent a consumer from becoming overloaded while keeping maximum memory usage deterministic. section 10.4.4

Use a bounded queue when:

Choosing queue behavior

A thread pool using a bounded queue can slow task producers when workers are busy, preventing the queue from growing indefinitely. An unbounded queue avoids that wait but can leave the consumer overloaded; asynchronous messages that cannot tolerate waiting may therefore require an unbounded queue. section 10.4.4

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Defines capacity, memory, and producer-waiting trade-offs but does not show bounded-queue implementation code.
Examples
Contrasts bounded and unbounded channel behavior in a thread-pool task-queue setting.
What it assumes
Assumes basic familiarity with channels, senders, receivers, producers, consumers, and worker threads.
What you can do after
Evaluate whether bounded or unbounded channel behavior fits a workload’s overload, memory, and waiting constraints.
How it connects
Connects bounded queues with channels, producers, consumers, back pressure, thread pools, task queues, and unbounded queues.

Also explained in

Compare how 3 books explain bounded queue →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.