Struct spmc_buffer::SPMCBuffer [] [src]

pub struct SPMCBuffer<T: Clone + PartialEq + Send> { /* fields omitted */ }

A single-producer multiple-consumer buffer, useful for thread-safe data sharing in scenarios where triple buffering won't cut it.

Triple buffering is an extremely efficient synchronization protocol when a producer thread wants to constantly update a value that is visible by a single consumer thread. However, it is not safe to use in the presence of multiple consumers, because a consumer thread can no longer assume that it is the only thread having access to the read buffer and discard said read buffer at will.

Reference counting techniques can be used to build a variant of triple buffering which works for multiple consumers, remains provably wait-free if one uses two buffers per consumer, and degrades gracefully when a smaller amount of buffers is used as long as consumers frequently fetch updates from the producer. I call the resulting synchronization primitive an SPMC buffer.

Methods

impl<T: Clone + PartialEq + Send> SPMCBuffer<T>
[src]

Construct an SPMC buffer allowing for wait-free writes under up to N concurrent readouts to distinct buffer versions

Extract input and output of the SPMC buffer

Trait Implementations

impl<T: Debug + Clone + PartialEq + Send> Debug for SPMCBuffer<T>
[src]

Formats the value using the given formatter.

impl<T: Clone + PartialEq + Send> Clone for SPMCBuffer<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Clone + PartialEq + Send> PartialEq for SPMCBuffer<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.