Struct mpmcpq::Stash

source ·
pub struct Stash<'a, M, P>where
    M: Send,
    P: PartialOrd + Ord,
{ /* private fields */ }
Expand description

For contention free queue insertion every thread maintains a private ‘stash’. When messages are send to the PriorityQueue while it is locked they are stored in this stash. Once the lock is obtained the stashed messages will be moved to the PriorityQueue. This can also be enforced with the ‘PriorityQueue::sync()’ function.

Implementations§

Creates a new stash. A stash is tied to a priority queue, when the stash becomes dropped all its remaining temporary messages will be sent to the queue.

Creates a new stash. This Stash has no reference to a priority queue, messages left here at drop time become discarded.

Returns true when the Stash contains no messages.

Returns the number of messages in the stash.

Examples found in repository?
src/mpmcpq.rs (line 139)
138
139
140
141
142
143
144
145
146
    pub fn send_batched(&self, message: M, prio: P, batch_size: usize, stash: &mut Stash<M, P>) {
        if stash.len() <= batch_size {
            // append to the stash
            self.send_stashed(message, prio, stash);
        } else {
            // try to send
            self.send(message, prio, stash);
        }
    }

Returns the number of messages the stash can hold without reallocating.

Trait Implementations§

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.