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>
impl<T: Copy> RawQueue<T>
sourcepub unsafe fn new(hdr: *const RawQueueHdr, buf: *mut QueueEntry<T>) -> Self
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.
sourcepub fn submit<W: Fn(&AtomicU64, u64), R: Fn(&AtomicU64)>(
&self,
item: QueueEntry<T>,
wait: W,
ring: R,
flags: SubmissionFlags,
) -> Result<(), QueueError>
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.
sourcepub fn receive<W: Fn(&AtomicU64, u64), R: Fn(&AtomicU64)>(
&self,
wait: W,
ring: R,
flags: ReceiveFlags,
) -> Result<QueueEntry<T>, QueueError>
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.