pub struct Resizable<Q> { /* private fields */ }Expand description
A dynamically resizable wrapper around a BoundedCollection.
This type implements an algorithm that allows any BoundedCollection to be dynamically resized while preserving some of its properties.
§Progress Guarantees:
- Lock Freedom: if the wrapped collection is lock-free, all corresponding operations on
Resizableare also lock-free. - Obstruction Freedom: if the wrapped collection exposes obstruction-free methods, all corresponding operations on
Resizableare also obstruction-free.
Resizable::resize is blocking both on allocator and stale readers and writers.
§Ordering and Consistency Guarantees:
- Relaxed FIFO: if the wrapped collection has FIFO ordering,
Resizablehas k-FIFO ordering with asymmetric delay and rank error. - Linearizability: if the wrapped collection is linearizable, all operations on
Resizableare also linearizable with respect to its relaxed FIFO specification. - Empty-Linearizability: if the wrapped collection is linearizale, all operations on
Resizableare empty-linearizable with respect to the wrapped collections specification.
If no call to resize happens, or in steady-state, Resizable has strict FIFO ordering and is strictly linearizable, given the same holds for the wrapped collection.
For more intormation on rank error and delay consult the crate level documentation.
Implementations§
Source§impl<Q> Resizable<Q>
impl<Q> Resizable<Q>
Sourcepub fn from_parts(left: Q, right: Q) -> Self
pub fn from_parts(left: Q, right: Q) -> Self
Constructs a new Resizable from two raw BoundedCollection objects.
Source§impl<Q> Resizable<Q>where
Q: BoundedCollection,
impl<Q> Resizable<Q>where
Q: BoundedCollection,
Source§impl<Q> Resizable<Q>where
Q: BoundedCollection,
impl<Q> Resizable<Q>where
Q: BoundedCollection,
Sourcepub fn resize(&self, size: usize) -> bool
pub fn resize(&self, size: usize) -> bool
Attempts to resize the capacity of the collection to size slots.
Note: This method may block (on the allocator) or fail spuriously.
Further a growth event may not be considered finished in regards of an other resize being possible until some time after the call to resize.
Returns true if the resize was successfull, or false if
it failed. Failure can occur due to thread
contention, incomplete migration of the previous resize, i.e. staleness of the datastructure,
or other implementation-specific/spurious conditions.
Source§impl<Q> Resizable<Q>
impl<Q> Resizable<Q>
Sourcepub fn into_parts(self) -> [Box<Q>; 2]
pub fn into_parts(self) -> [Box<Q>; 2]
Deconstructs a Resizable into its components.
Returns the left and right raw collections currently used by this object.
Sourcepub fn parts_mut(&mut self) -> [&mut Q; 2]
pub fn parts_mut(&mut self) -> [&mut Q; 2]
returns mutable references to both wrapped collections.
Sourcepub fn into_current(self) -> Box<Q>
pub fn into_current(self) -> Box<Q>
Deconstructs a Resizable into its currently active component.
Returns the raw collection currently used by this object.
Sourcepub fn current_mut(&mut self) -> &mut Q
pub fn current_mut(&mut self) -> &mut Q
Returns a mutable reference to the currently active raw collection.
Source§impl<Q> Resizable<Q>where
Q: BoundedCollection,
impl<Q> Resizable<Q>where
Q: BoundedCollection,
Sourcepub fn pop_mut(&mut self) -> Option<Q::Item>
pub fn pop_mut(&mut self) -> Option<Q::Item>
Attempts to pop an item from the collection.
This method cicumvents the logic synchronization of Resizable::try_pop.
Trait Implementations§
Source§impl<Q> BoundedCollection for Resizable<Q>where
Q: BoundedCollection,
impl<Q> BoundedCollection for Resizable<Q>where
Q: BoundedCollection,
Source§type Item = <Q as BoundedCollection>::Item
type Item = <Q as BoundedCollection>::Item
Source§fn try_push(&self, item: Self::Item) -> Result<(), Self::Item>
fn try_push(&self, item: Self::Item) -> Result<(), Self::Item>
Source§fn try_pop(&self) -> Option<Self::Item>
fn try_pop(&self) -> Option<Self::Item>
None if the collection is empty.Source§fn len(&self) -> usize
fn len(&self) -> usize
Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Source§fn is_full(&self) -> bool
fn is_full(&self) -> bool
Source§fn with_capacity(capacity: usize) -> Self
fn with_capacity(capacity: usize) -> Self
capacity. Read moreSource§impl<Q: BoundedCollection> Extend<<Q as BoundedCollection>::Item> for Resizable<Q>
Available on neither echeneis nor loom nor shuttle.
impl<Q: BoundedCollection> Extend<<Q as BoundedCollection>::Item> for Resizable<Q>
echeneis nor loom nor shuttle.Source§fn extend<I: IntoIterator<Item = Q::Item>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Q::Item>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<Q: BoundedCollection> IntoIterator for Resizable<Q>
Available on neither echeneis nor loom nor shuttle.
impl<Q: BoundedCollection> IntoIterator for Resizable<Q>
echeneis nor loom nor shuttle.