#spmc #atomic #non-blocking #lock-free


Efficient single-producer multi-consumer channel types

2 unstable releases

0.2.1 Jan 3, 2023
0.2.0 Jan 2, 2023
0.1.5 Mar 27, 2022

#379 in Concurrency

43 downloads per month


479 lines


Efficient single-producer multi-consumer channel types.

See crate documentation for details.


Bombs, a whole load of 'em.

This crate provides single-producer multi-consumer channel types, where Fuses are the producers and Bombs are the consumers.

Fuse/Bombs are one-time use only, whereas MultiFuse/MultiBombs can be reused, and store values sent through the channel in a queue.

For non-blocking channels, see the crate-level types. For blocking channels, see the types in the blocking module.


If you want to send a "close program" signal to different threads, such that each thread needs to clean up first before closing, you can give each thread a Bomb<()>, and run cleanup code once exploded.

Note: This example assumes that your threads already run logic in some event loop. It is advised to use the blocking variants instead of checking exploded() in a loop.

use std::thread;
use bombs::blocking::Bomb;

// Create a new fuse and bomb pair.
let (fuse, bomb) = Bomb::new();

// Clone `bomb` into thread.
let bomb_clone = bomb.clone();
thread::spawn(move || {
    loop {
        // Do some stuff...

        if let Some(_) = bomb_clone.exploded() {
            // Received close signal, break.

            // Clean up data values...


// Create another thread.
// Move original `bomb` into thread.
thread::spawn(move || {
    loop {
        // Do some other stuff...

        if let Some(_) = bomb.exploded() {
            // Received close signal, break.

            // Clean up data values...


// Do some different stuff...

// Send close signal.
let flame = fuse.light(());

// Wait for all inner threads to close safely (checked by `Bomb` drop).

// Now safely quit the program.


~464K SLoC