Circus Ring Buffer
A burst of performers is arriving faster than the ringmaster can announce them. Store each act in a fixed circle, serve the oldest ticket first, and never overwrite a waiting performer.
π§ Before we start
Circus Event Relay sent signals between acts. Today, a circular queue safely holds a burst of those signals: new work joins at the tail, old work leaves from the head, and both pointers wrap around reusable slots.
Build the ringmaster's rules
Tap the visual instruction blocks in order. A bounded queue checks for room, stores at the tail, serves from the head, then reuses slots by wrapping.
Keep first-in, first-out
Add Lion, Clown, then Trapeze. Serve two acts. The head must always point to the oldest waiting ticket.
Wrap without shuffling
Two acts wait near the end of the ring. Add two more acts and serve two. Move only the pointersβthe stored tickets do not need to slide.
Protect a full ring
All five slots are occupied and one more act arrives. Choose a backpressure rule that keeps every accepted ticket safe and preserves order.
π What you learned
- A queue serves work in first-in, first-out order.
- The tail points to the next slot where a producer adds work.
- The head points to the oldest slot a consumer serves.
- A circular buffer reuses fixed slots by wrapping pointers to the beginning.
- Head, tail, and size distinguish an empty ring from a full ring.
- Backpressure pauses a fast producer instead of overwriting accepted work.