Skip to main content

MCache

Struct MCache 

Source
pub struct MCache<const DEPTH: usize> { /* private fields */ }

Implementations§

Source§

impl<const DEPTH: usize> MCache<DEPTH>

Source

pub fn new() -> Self

Create a ring buffer with a power-of-two number of slots.

Source

pub fn stop(&self)

Source

pub fn is_running(&self) -> bool

Source

pub fn publish(&self, meta: FragmentMetadata)

Publish a fragment’s metadata into the ring.

Source

pub fn wait(&self, seq: u64) -> ReadResult<FragmentMetadata>

Busy-wait for a specific sequence number to appear.

Returns:

  • ReadResult::Ok(meta) if the sequence was successfully read
  • ReadResult::Overrun if the consumer was lapped by the producer
  • ReadResult::NotReady if the mcache was stopped before the sequence appeared
Source

pub fn try_read(&self, seq: u64) -> ReadResult<FragmentMetadata>

Attempt a lock-free read of the metadata at a specific sequence.

Returns:

  • ReadResult::Ok(meta) if the sequence was successfully read
  • ReadResult::NotReady if the sequence has not been published yet
  • ReadResult::Overrun if the consumer was lapped by the producer

Trait Implementations§

Source§

impl<const DEPTH: usize> Debug for MCache<DEPTH>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const DEPTH: usize> Default for MCache<DEPTH>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const DEPTH: usize> !Freeze for MCache<DEPTH>

§

impl<const DEPTH: usize> !RefUnwindSafe for MCache<DEPTH>

§

impl<const DEPTH: usize> Send for MCache<DEPTH>

§

impl<const DEPTH: usize> Sync for MCache<DEPTH>

§

impl<const DEPTH: usize> Unpin for MCache<DEPTH>

§

impl<const DEPTH: usize> UnsafeUnpin for MCache<DEPTH>

§

impl<const DEPTH: usize> UnwindSafe for MCache<DEPTH>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.