pub struct RingBuffer<T> { /* private fields */ }Expand description
Ring Buffer.
Implementations§
Source§impl<T> RingBuffer<T>
impl<T> RingBuffer<T>
Sourcepub fn new<F>(factory: F, size: usize, sequencer: Arc<dyn Sequencer>) -> Selfwhere
F: Fn() -> T,
pub fn new<F>(factory: F, size: usize, sequencer: Arc<dyn Sequencer>) -> Selfwhere
F: Fn() -> T,
Creates a new ring buffer with the given factory, size, and sequencer.
Sourcepub fn add_gating_sequences(&self, sequences: Vec<Arc<Sequence>>)
pub fn add_gating_sequences(&self, sequences: Vec<Arc<Sequence>>)
Adds gating sequences to the sequencer.
Sourcepub unsafe fn get(&self, sequence: i64) -> &T
pub unsafe fn get(&self, sequence: i64) -> &T
Gets a reference to the event at the given sequence.
§Safety
The caller must guarantee that sequence has been fully published by the
producer (i.e., publish(sequence) was called and observed) and that
no other thread is concurrently writing to the same slot. Within the
Disruptor protocol this is established by waiting on a
ProcessingSequenceBarrier before calling this method. Calling it with
an unpublished sequence or while a producer holds the slot is undefined
behaviour.
Sourcepub fn get_mut(&mut self, sequence: i64) -> &mut T
pub fn get_mut(&mut self, sequence: i64) -> &mut T
Gets a mutable reference to the event at the given sequence.
Sourcepub unsafe fn get_unchecked(&self, sequence: i64) -> &T
pub unsafe fn get_unchecked(&self, sequence: i64) -> &T
Unsafe access for high performance (internal use).
§Safety
The caller must ensure that the sequence number is valid and that no other thread is concurrently modifying the same slot.
Sourcepub unsafe fn get_unchecked_mut(&self, sequence: i64) -> &mut T
pub unsafe fn get_unchecked_mut(&self, sequence: i64) -> &mut T
Unsafe mutable access for high performance (internal use).
§Safety
The caller must ensure that the sequence number is valid and that they have exclusive access to the slot (e.g., via the Disruptor protocol).