[][src]Struct syscall::io_uring::v1::Ring

#[repr(C)]pub struct Ring<T> {
    pub base_rel: usize,
    pub size: usize,
    pub head_idx: CachePadded<AtomicUsize>,
    pub tail_idx: CachePadded<AtomicUsize>,
    pub sts: CachePadded<AtomicUsize>,
    pub push_epoch: CachePadded<AtomicUsize>,
    pub pop_epoch: CachePadded<AtomicUsize>,
    pub _marker: PhantomData<*mut T>,
}

The raw data structure of the ring, shared with the producer(s) and consumer(s) using it.

Fields

base_rel: usize

The byte offset relative to the base pointer of the entries mmap.

size: usize

The unchangable number of entries in the ring.

head_idx: CachePadded<AtomicUsize>

Index of the head pointer with various information encoded together with it.

tail_idx: CachePadded<AtomicUsize>

Index of the tail pointer with various information encoded together with it.

sts: CachePadded<AtomicUsize>

Status, used to implement shutdown.

push_epoch: CachePadded<AtomicUsize>

A global epoch counter, used by the kernel to compare different "versions" of the ring, so that the kernel may send a notification event to a process without the notifier even making a syscall.

This field can and should be used by futexes when notifying another process.

pop_epoch: CachePadded<AtomicUsize>

Functions similarly to push_epoch, except it counts the pop operations, in order to be able to notify producers whose queue was full (more unlikely than the consumer getting an empty queue).

_marker: PhantomData<*mut T>

Makes the Rust compiler believe that we own a *mut T.

Implementations

impl<T> Ring<T>[src]

pub fn min_extra_bits() -> u8[src]

The number of bits that aren't otherwise useful for indexing, since any type with a >1 size can overflow when multiplying the index with the stride of that type. Two bits of these are always assumed to be free accessible, so a Ring of u8s will not be able to store usize::max_value() items, unfortunately.

pub fn extra_bits(&self) -> u8[src]

The number of bits that can be used to store other information alongside the index inside each tail or head pointer word. For MPMC, this allows these bits to be used for storing TODO. This does not include the extra bit required for the implicit cycle.

pub fn usable_extra_bits(&self) -> u8[src]

pub unsafe fn push_back_generic(
    &self,
    entries_base: *mut T,
    item: T,
    spsc: bool
) -> Result<(), RingPushError<T>>
[src]

Pushes an item onto the back of the queue (tail). The tail index is incremented twice, so that other threads can notice that this thread is currently writing the item.

pub unsafe fn push_back(
    &self,
    entries_base: *mut T,
    item: T
) -> Result<(), RingPushError<T>>
[src]

pub unsafe fn push_back_spsc(
    &self,
    entries_base: *mut T,
    item: T
) -> Result<(), RingPushError<T>>
[src]

pub unsafe fn pop_front_generic(
    &self,
    entries_base: *const T,
    spsc: bool
) -> Result<T, RingPopError>
[src]

pub unsafe fn pop_front(
    &self,
    entries_base: *const T
) -> Result<T, RingPopError>
[src]

pub unsafe fn pop_front_spsc(
    &self,
    entries_base: *const T
) -> Result<T, RingPopError>
[src]

pub fn available_entry_count_generic(&self, spsc: bool) -> usize[src]

Returns the number of entries that can be popped, at the time the function was called.

pub fn available_entry_count_spsc(&self) -> usize[src]

pub fn available_entry_count(&self) -> usize[src]

pub fn free_entry_count_generic(&self, spsc: bool) -> usize[src]

Returns the number of entries that can be pushed, at the time the function was called.

pub fn free_entry_count_spsc(&self) -> usize[src]

pub fn free_entry_count(&self) -> usize[src]

Auto Trait Implementations

impl<T> !Send for Ring<T>

impl<T> !Sync for Ring<T>

impl<T> Unpin for Ring<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.