Skip to main content

Crate scatto

Crate scatto 

Source
Expand description

low-latency inter-thread communication inspired by lmax disruptor.

this crate provides zero-copy, lock-free channels for high-performance applications.

§features

  • pre-allocated ring buffers (no allocation in hot path)
  • sequence-based coordination (no locks)
  • multiple wait strategies for latency/CPU trade-offs
  • zero-copy in-place mutation support
  • cache-line padding to prevent false sharing

§channel types

  • spsc: single producer single consumer - lowest latency
  • mpsc: multi producer single consumer - multiple senders

§example

use scatto::spsc;

// create channel with 1024-slot buffer
let (mut producer, mut consumer) = spsc::channel::<u64>(1024);

// producer thread
std::thread::spawn(move || {
    for i in 0..1000 {
        producer.send(i).unwrap();
    }
});

// consumer
for _ in 0..1000 {
    let value = consumer.recv().unwrap();
}

Re-exports§

pub use error::RecvError;
pub use error::SendError;
pub use error::TryRecvError;
pub use error::TrySendError;
pub use ringbuffer::RingBuffer;

Modules§

barrier
sequence barriers for coordinating producer-consumer dependencies.
error
error types for channel operations.
mpsc
multi producer single consumer (MPSC) channel.
ringbuffer
pre-allocated ring buffer storage.
spsc
single producer single consumer (SPSC) channel.
wait_strategy

Structs§

BackoffWait
BusySpinWait
CachePadded
Cursor
SpinLoopHintWait
YieldingWait

Constants§

CACHE_LINE_SIZE
INITIAL_CURSOR_VALUE

Traits§

WaitStrategy

Functions§

cpu_pause
fence_acq_rel
fence_acquire
fence_release