twizzler_queue_raw

Struct RawQueue

source
pub struct RawQueue<T> { /* private fields */ }
Expand description

A raw queue, comprising of a header to track the algorithm and a buffer to hold queue entries.

Implementations§

source§

impl<T: Copy> RawQueue<T>

source

pub unsafe fn new(hdr: *const RawQueueHdr, buf: *mut QueueEntry<T>) -> Self

Construct a new raw queue out of a header reference and a buffer pointer.

§Safety

The caller must ensure that hdr and buf point to valid objects, and that the lifetime of the RawQueue is exceeded by the objects pointed to.

source

pub fn submit<W: Fn(&AtomicU64, u64), R: Fn(&AtomicU64)>( &self, item: QueueEntry<T>, wait: W, ring: R, flags: SubmissionFlags, ) -> Result<(), QueueError>

Submit a data item of type T, wrapped in a QueueEntry, to the queue. The two callbacks, wait, and ring, are for implementing a rudimentary condvar, wherein if the queue needs to block, we’ll call wait(x, y), where we are supposed to wait until *x != y. Once we are done inserting, if we need to wake up a consumer, we will call ring, which should wake up anyone waiting on that word of memory.

source

pub fn receive<W: Fn(&AtomicU64, u64), R: Fn(&AtomicU64)>( &self, wait: W, ring: R, flags: ReceiveFlags, ) -> Result<QueueEntry<T>, QueueError>

Receive data from the queue, returning either that data or an error. The wait and ring callbacks work similar to RawQueue::submit.

source

pub fn setup_sleep<'a>( &'a self, sleep: bool, output: &mut Option<QueueEntry<T>>, waiter: &mut (Option<&'a AtomicU64>, u64), ringer: &mut Option<&'a AtomicU64>, ) -> Result<(), QueueError>

source

pub fn setup_sleep_simple(&self) -> (&AtomicU64, u64)

source

pub fn setup_send_sleep_simple(&self) -> (&AtomicU64, u64)

Trait Implementations§

source§

impl<T: Send> Send for RawQueue<T>

source§

impl<T: Send> Sync for RawQueue<T>

Auto Trait Implementations§

§

impl<T> !Freeze for RawQueue<T>

§

impl<T> !ObjSafe for RawQueue<T>

§

impl<T> !RefUnwindSafe for RawQueue<T>

§

impl<T> Unpin for RawQueue<T>

§

impl<T> UnwindSafe for RawQueue<T>
where T: RefUnwindSafe,

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.