Struct bagpipe::BagPipe
[−]
[src]
pub struct BagPipe<B: SharedWeakBag> { /* fields omitted */ }
A concurrent bag data-structure built from sharding requests over other bags.
BagPipe
implements both SharedWeakBag
and WeakBag
. Using this
as a SharedWeakBag
tends to perform worse. Note that this should
never be used with Arc<BagPipe>
, which will be much slower and
have an increased failure rate.
Methods
impl<B: SharedWeakBag> BagPipe<B>
[src]
fn new_size(size: usize) -> Self
[src]
Create a new BagPipe
with size
pipes.
fn size_guess(&self) -> isize
[src]
Return a guess of the current BagPipe
size.
This is implemented in a way that seeks to reduce overhead as
much as possible. Currently there are 4 AtomicIsize
counters
in the global BagPipeState
struct; one of these is updated
when a thread accumulates a local diff (i.e. net pushes or pops)
greater than a certain small constant. A thread querying the
size of the BagPipe
then simply sums these counters.
Given this algorithm there are no consistency guarantees on this counter, not even eventual consistency. A counter is updated upon drop, so one "consistency guarantee" is that of a very weak quiescent consistency when "quiesce" means all threads that have pushed or popped from the data-structure have relinquished a handle on it. Note that this term usually refers to a sufficiently long period of inactivity.
impl<B: RevocableWeakBag> BagPipe<B> where
B::Item: Revocable,
[src]
B::Item: Revocable,
unsafe fn revoke(it: &B::Item) -> bool
[src]
Attempt to revoke it
from membership in the BagPipe
.
This is simply an implementation of portions of the Revocable
trait for a BagPipe
. We don't implement the trait here
because it inherits from SharedWeakBag and BagPipes have
unexpected behavior when used without the _mut() methods. This
problem could be solved if we had "or" trait inheritance, but
that could be more trouble than its worth :-)
Trait Implementations
impl<B: SharedWeakBag> Drop for BagPipe<B>
[src]
impl<B: SharedWeakBag> Clone for BagPipe<B>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<B: SharedWeakBag> WeakBag for BagPipe<B>
[src]
type Item = B::Item
fn new() -> Self
[src]
fn try_push_mut(&mut self, it: Self::Item) -> Result<(), Self::Item>
[src]
fn try_pop_mut(&mut self) -> PopResult<Self::Item>
[src]
fn push_mut(&mut self, it: Self::Item)
[src]
fn bulk_add<I: Iterator<Item = Self::Item>>(&mut self, iter: I)
[src]
Add all items in I
to the WeakBag
. Read more