LockFreeBatchReceiver

Trait LockFreeBatchReceiver 

Source
pub trait LockFreeBatchReceiver<T> {
    // Required method
    unsafe fn lock_free_push_many_and_slice_and_commit_if<F, FSuccess, FError>(
        &self,
        first: &[T],
        last: &[T],
        slice: &[T],
        f: F,
    ) -> Result<FSuccess, LockFreePushBatchErr<(), FError>>
       where F: FnOnce() -> Result<FSuccess, FError>;

    // Provided method
    unsafe fn push_many_and_one_and_commit_if<F, FSuccess, FError>(
        &self,
        first: &[T],
        last: &[T],
        value: T,
        f: F,
    ) -> Result<FSuccess, LockFreePushBatchErr<T, FError>>
       where F: FnOnce() -> Result<FSuccess, FError> { ... }
}
Expand description

A lock-free batch receiver of the multi-consumer queue. It is used to move half of the values from the queue to this receiver on overflow.

This library provides the MutexVecQueue that implements this trait.

Required Methods§

Source

unsafe fn lock_free_push_many_and_slice_and_commit_if<F, FSuccess, FError>( &self, first: &[T], last: &[T], slice: &[T], f: F, ) -> Result<FSuccess, LockFreePushBatchErr<(), FError>>
where F: FnOnce() -> Result<FSuccess, FError>,

Pushes a batch of values to the receiver but commits it only if the function returns true.

It first pushes the first slice, then the last slice and finally the slice.

It has such an interesting signature because it can be used in ring-based queues.

It is lock-free.

§Safety

If T is not Copy and the operation succeeds, the caller should forget the provided slices.

Provided Methods§

Source

unsafe fn push_many_and_one_and_commit_if<F, FSuccess, FError>( &self, first: &[T], last: &[T], value: T, f: F, ) -> Result<FSuccess, LockFreePushBatchErr<T, FError>>
where F: FnOnce() -> Result<FSuccess, FError>,

Pushes a batch of values to the receiver but commits it only if the function returns true.

It first pushes the first slice, then the last slice and finally the value.

It has such an interesting signature because it can be used in ring-based queues.

It is lock-free.

§Safety

If T is not Copy and the operation succeeds, the caller should forget the provided slices and the provided value.

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.

Implementors§