[−][src]Struct unicycle::AtomicBitSet
The same as BitSet, except it provides atomic methods.
BitSet and AtomicBitSet's are guaranteed to have an identical memory
layout, so while it would require unsafe
, transmuting or coercing between
the two is sound assuming the proper synchronization is respected.
We provide the following methods to accomplish this from an atomic bitset, to a local (non atomic) one: as_local_mut for borrowing mutably and into_local.
Methods
impl AtomicBitSet
[src]
pub fn new() -> Self
[src]
Construct a new, empty atomic bit set.
Examples
use unicycle::AtomicBitSet; let set = AtomicBitSet::new(); let set = set.into_local(); assert!(set.is_empty());
pub fn set(&self, position: usize)
[src]
Set the given bit atomically.
We can do this to an AtomicBitSet since the required modifications that needs to be performed against each layer are idempotent of the order in which they are applied.
Panics
Call will panic if the position is not within the capacity of the AtomicBitSet.
Examples
use unicycle::BitSet; let set = BitSet::with_capacity(1024).into_atomic(); set.set(1000); let set = set.into_local(); assert!(set.test(1000));
pub fn into_local(self) -> BitSet
[src]
Convert in-place into a a BitSet
.
This is safe, since this function requires exclusive owned access to the AtomicBitSet, and we assert that their memory layouts are identical.
Examples
use unicycle::BitSet; let mut set = BitSet::new(); set.reserve(1024); let atomic = set.into_atomic(); atomic.set(42); let set = atomic.into_local(); assert!(set.test(42));
pub fn as_local_mut(&mut self) -> &mut BitSet
[src]
Convert in-place into a mutable reference to a BitSet
.
This is safe, since this function requires exclusive mutable access to the AtomicBitSet, and we assert that their memory layouts are identical.
Examples
use unicycle::BitSet; let mut set = BitSet::with_capacity(1024).into_atomic(); set.set(21); set.set(42); { let set = set.as_local_mut(); // Clearing is only safe with BitSet's since we require exclusive // mutable access to the collection being cleared. set.clear(21); } let set = set.into_local(); assert!(!set.test(21)); assert!(set.test(42));
Trait Implementations
impl Default for AtomicBitSet
[src]
Auto Trait Implementations
impl RefUnwindSafe for AtomicBitSet
impl Send for AtomicBitSet
impl Sync for AtomicBitSet
impl Unpin for AtomicBitSet
impl UnwindSafe for AtomicBitSet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,