pub trait LockFreeConsumer<T>: Consumer<T> {
// Required method
fn lock_free_pop_many(&self, dst: &mut [MaybeUninit<T>]) -> (usize, bool);
// Provided methods
fn lock_free_pop(&self) -> Result<T, LockFreePopErr> { ... }
fn lock_free_steal_into(
&self,
dst: &impl SingleLockFreeProducer<T>,
) -> (usize, bool) { ... }
}Expand description
A lock-free consumer of a queue.
Required Methods§
Sourcefn lock_free_pop_many(&self, dst: &mut [MaybeUninit<T>]) -> (usize, bool)
fn lock_free_pop_many(&self, dst: &mut [MaybeUninit<T>]) -> (usize, bool)
Pops many values from the queue. Returns the number of popped values and whether the operation failed because it should wait.
It is lock-free.
If you can lock, you can look at the Consumer::pop_many method
because if it is implemented not as lock-free, it should have better performance.
Provided Methods§
Sourcefn lock_free_pop(&self) -> Result<T, LockFreePopErr>
fn lock_free_pop(&self) -> Result<T, LockFreePopErr>
Pops a value from the queue. On failure, returns Err(.LockFreePopErr)
It is lock-free.
If you can lock, you can look at the Consumer::pop method
because if it is implemented not as lock-free, it should have better performance.
Sourcefn lock_free_steal_into(
&self,
dst: &impl SingleLockFreeProducer<T>,
) -> (usize, bool)
fn lock_free_steal_into( &self, dst: &impl SingleLockFreeProducer<T>, ) -> (usize, bool)
Steals some values from the consumer and places them into dst.
Returns the number of stolen values and whether the operation failed
because it should wait.
It requires that the other queue to be empty. Expected to steal the half of the queue, but other implementations may steal another number of values.
It is lock-free.
If you can lock, you can look at the Consumer::steal_into method
because if it is implemented not as lock-free, it should have better performance.
§Panics
Panics if the other queue is not empty.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.