Cursor

Struct Cursor 

Source
pub struct Cursor<T: Copy> { /* private fields */ }
Expand description

A structure for tracking a ring shared between a producer and consumer

See xsk.h.

Implementations§

Source§

impl<T: Copy> Cursor<T>

Source

pub fn producer(&self) -> &AtomicU32

Returns a reference to the producer atomic cursor

Source

pub fn consumer(&self) -> &AtomicU32

Returns a reference to the producer atomic cursor

Source

pub const fn capacity(&self) -> u32

Returns the overall size of the ring

Source

pub fn acquire_producer(&mut self, watermark: u32) -> u32

Acquires a cursor index for a producer half

The watermark can be provided to avoid synchronization by reusing the cached cursor value.

See xsk.h.

Source

pub fn cached_producer(&self) -> u32

Returns the cached producer cursor which is also maxed by the cursor mask

See xsk.h.

Source

pub fn cached_producer_len(&self) -> u32

Returns the cached number of available entries for the consumer

See xsk.h.

Source

pub fn release_producer(&mut self, len: u32)

Releases a len number of entries from the producer to the consumer.

See xsk.h.

The provided len should not exceed the number from acquire_producer. With debug_assertions enabled, this will panic if it occurs.

Source

pub fn acquire_consumer(&mut self, watermark: u32) -> u32

Acquires a cursor index for a consumer half

The watermark can be provided to avoid synchronization by reusing the cached cursor value.

See xsk.h.

Source

pub fn cached_consumer(&self) -> u32

Returns the cached consumer cursor which is also maxed by the cursor mask

See xsk.h.

Source

pub fn cached_consumer_len(&self) -> u32

Returns the cached number of available entries for the consumer

See xsk.h.

Source

pub fn release_consumer(&mut self, len: u32)

Releases a len number of entries from the consumer to the producer.

See xsk.h.

The provided len should not exceed the number from acquire_consumer. With debug_assertions enabled, this will panic if it occurs.

Source

pub unsafe fn consumer_data(&mut self) -> (&mut [T], &mut [T])

Returns the current consumer entries

§Safety

This function MUST only be used by the consumer side.

Source

pub unsafe fn producer_data(&mut self) -> (&mut [T], &mut [T])

Returns the current producer entries

§Safety

This function MUST only be used by the producer side.

Source

pub const fn data_ptr(&self) -> NonNull<T>

Trait Implementations§

Source§

impl<T: Debug + Copy> Debug for Cursor<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Cursor<T>

§

impl<T> RefUnwindSafe for Cursor<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Cursor<T>

§

impl<T> !Sync for Cursor<T>

§

impl<T> Unpin for Cursor<T>
where T: Unpin,

§

impl<T> UnwindSafe for Cursor<T>

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.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T