pub struct BoundedQueue<T, I, RING, const SEAL: usize>where
I: Sealed,{ /* private fields */ }Expand description
The bounded queue type from the ACM paper. This uses two SCQ rings internally, one that keeps track of free indices and the other that keeps track of the allocated indices.
Implementations§
Source§impl<T, const N: usize> BoundedQueue<T, [UnsafeCell<Option<T>>; N], [CachePadded<AtomicUsize>; N], 0>
impl<T, const N: usize> BoundedQueue<T, [UnsafeCell<Option<T>>; N], [CachePadded<AtomicUsize>; N], 0>
Sourcepub fn new_const() -> Self
pub fn new_const() -> Self
A helper function for creating constant bounded queues, will automatically try to calculate the correct order.
§Panics
This function will panic if the value is not a power of two and also if the value is zero as we cannot initialize zero sized constant bounded queues.
§Example
use lfqueue::{ConstBoundedQueue, ScqError};
let queue = ConstBoundedQueue::<usize, 4>::new_const();
assert!(queue.enqueue(2).is_ok());
assert!(queue.enqueue(3).is_ok());
assert_eq!(queue.enqueue(4), Err(ScqError::QueueFull));Source§impl<T, I, P, const S: usize> BoundedQueue<T, I, P, S>
impl<T, I, P, const S: usize> BoundedQueue<T, I, P, S>
pub const MAX_ORDER: usize = 63usize
pub const MIN_ORDER: usize = 0usize
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of the bounded ring. This is 2 ^ order.
§Example
use lfqueue::ConstBoundedQueue;
let value = ConstBoundedQueue::<usize, 4>::new_const();
assert_eq!(value.capacity(), 2);Source§impl<T, const MODE: usize> BoundedQueue<T, Box<[UnsafeCell<Option<T>>]>, Box<[CachePadded<AtomicUsize>]>, MODE>
impl<T, const MODE: usize> BoundedQueue<T, Box<[UnsafeCell<Option<T>>]>, Box<[CachePadded<AtomicUsize>]>, MODE>
Trait Implementations§
Source§impl<T: Debug, I, RING: Debug, const SEAL: usize> Debug for BoundedQueue<T, I, RING, SEAL>where
I: Sealed + Debug,
impl<T: Debug, I, RING: Debug, const SEAL: usize> Debug for BoundedQueue<T, I, RING, SEAL>where
I: Sealed + Debug,
impl<T: Send + Sync, I: Sealed, R, const SEAL: usize> Send for BoundedQueue<T, I, R, SEAL>
impl<T: Send + Sync, I: Sealed, R, const SEAL: usize> Sync for BoundedQueue<T, I, R, SEAL>
Auto Trait Implementations§
impl<T, I, RING, const SEAL: usize> !Freeze for BoundedQueue<T, I, RING, SEAL>
impl<T, I, RING, const SEAL: usize> RefUnwindSafe for BoundedQueue<T, I, RING, SEAL>
impl<T, I, RING, const SEAL: usize> Unpin for BoundedQueue<T, I, RING, SEAL>
impl<T, I, RING, const SEAL: usize> UnwindSafe for BoundedQueue<T, I, RING, SEAL>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more