pub struct AtomicBitfieldContainer<T: NoUninit>(/* private fields */);Expand description
Atomic container for bitfield storage.
Implementations§
Source§impl<T: NoUninit + FromPrimitive + ToPrimitive + PrimInt> AtomicBitfieldContainer<T>
impl<T: NoUninit + FromPrimitive + ToPrimitive + PrimInt> AtomicBitfieldContainer<T>
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Creates the new bitfield container.
Examples found in repository?
7fn main() {
8 let mut storage;
9
10 storage = A::encode(true);
11 assert!(A::decode(storage));
12 storage = B::update(-1, storage);
13 assert_eq!(B::decode(storage), -1);
14 storage = B::update(2, storage);
15 assert_eq!(B::decode(storage), 2);
16 assert!(A::decode(storage));
17 assert_eq!(C::decode(storage), 0);
18 assert!(B::is_valid(7));
19 assert!(!B::is_valid(8));
20 assert!(B::is_valid(-8));
21 assert!(!B::is_valid(-9));
22
23 println!("Creating atomic bitfield storage");
24
25 type LockBit = BitField<usize, bool, 0, 1, false>;
26 type DataBits = BitField<usize, u32, { LockBit::NEXT_BIT }, 32, false>;
27
28 let container = std::sync::Arc::new(AtomicBitfieldContainer::new(0usize));
29 println!(
30 "lock bit: {}, data bits: {}",
31 container.read::<LockBit>(),
32 container.read::<DataBits>()
33 );
34 let thread = {
35 let container = container.clone();
36
37 std::thread::spawn(move || {
38 println!("thread 1 spawned");
39 while !container.try_acquire::<LockBit>() {}
40 container.update::<DataBits>(42);
41 println!(
42 "thread 1: set data bits to {}",
43 container.read::<DataBits>()
44 );
45 assert!(container.try_release::<LockBit>());
46 })
47 };
48
49 loop {
50 while !container.try_acquire::<LockBit>() {
51 std::thread::yield_now();
52 }
53 if container.read::<DataBits>() != 0 {
54 println!("data bits is not zero, break");
55 assert_eq!(container.read::<DataBits>(), 42);
56 assert!(container.try_release::<LockBit>());
57 break;
58 }
59
60 println!("data bits is zero, loop");
61
62 assert!(container.try_release::<LockBit>());
63 }
64 println!("{}", container.read::<DataBits>());
65 thread.join().unwrap();
66}Sourcepub fn load_ignore_race(&self) -> T
pub fn load_ignore_race(&self) -> T
Load underlying value of container ignoring atomic access
Sourcepub fn store(&self, value: T, order: Ordering)
pub fn store(&self, value: T, order: Ordering)
Store new value to container with order ordering.
Sourcepub fn compare_exchange_weak(
&self,
current: T,
new: T,
success: Ordering,
failure: Ordering,
) -> Result<T, T>
pub fn compare_exchange_weak( &self, current: T, new: T, success: Ordering, failure: Ordering, ) -> Result<T, T>
Perform CAS, equivalent to compare_exchange_weak
in any std type.
Sourcepub fn read<B: BitFieldTrait<T>>(&self) -> B::Type
pub fn read<B: BitFieldTrait<T>>(&self) -> B::Type
Use bitfield B to decode the value in container and return the value.
Examples found in repository?
7fn main() {
8 let mut storage;
9
10 storage = A::encode(true);
11 assert!(A::decode(storage));
12 storage = B::update(-1, storage);
13 assert_eq!(B::decode(storage), -1);
14 storage = B::update(2, storage);
15 assert_eq!(B::decode(storage), 2);
16 assert!(A::decode(storage));
17 assert_eq!(C::decode(storage), 0);
18 assert!(B::is_valid(7));
19 assert!(!B::is_valid(8));
20 assert!(B::is_valid(-8));
21 assert!(!B::is_valid(-9));
22
23 println!("Creating atomic bitfield storage");
24
25 type LockBit = BitField<usize, bool, 0, 1, false>;
26 type DataBits = BitField<usize, u32, { LockBit::NEXT_BIT }, 32, false>;
27
28 let container = std::sync::Arc::new(AtomicBitfieldContainer::new(0usize));
29 println!(
30 "lock bit: {}, data bits: {}",
31 container.read::<LockBit>(),
32 container.read::<DataBits>()
33 );
34 let thread = {
35 let container = container.clone();
36
37 std::thread::spawn(move || {
38 println!("thread 1 spawned");
39 while !container.try_acquire::<LockBit>() {}
40 container.update::<DataBits>(42);
41 println!(
42 "thread 1: set data bits to {}",
43 container.read::<DataBits>()
44 );
45 assert!(container.try_release::<LockBit>());
46 })
47 };
48
49 loop {
50 while !container.try_acquire::<LockBit>() {
51 std::thread::yield_now();
52 }
53 if container.read::<DataBits>() != 0 {
54 println!("data bits is not zero, break");
55 assert_eq!(container.read::<DataBits>(), 42);
56 assert!(container.try_release::<LockBit>());
57 break;
58 }
59
60 println!("data bits is zero, loop");
61
62 assert!(container.try_release::<LockBit>());
63 }
64 println!("{}", container.read::<DataBits>());
65 thread.join().unwrap();
66}Sourcepub fn update<B: BitFieldTrait<T>>(&self, value: B::Type)
pub fn update<B: BitFieldTrait<T>>(&self, value: B::Type)
Update container according to bitfield B, performs CAS under the hood.
Examples found in repository?
7fn main() {
8 let mut storage;
9
10 storage = A::encode(true);
11 assert!(A::decode(storage));
12 storage = B::update(-1, storage);
13 assert_eq!(B::decode(storage), -1);
14 storage = B::update(2, storage);
15 assert_eq!(B::decode(storage), 2);
16 assert!(A::decode(storage));
17 assert_eq!(C::decode(storage), 0);
18 assert!(B::is_valid(7));
19 assert!(!B::is_valid(8));
20 assert!(B::is_valid(-8));
21 assert!(!B::is_valid(-9));
22
23 println!("Creating atomic bitfield storage");
24
25 type LockBit = BitField<usize, bool, 0, 1, false>;
26 type DataBits = BitField<usize, u32, { LockBit::NEXT_BIT }, 32, false>;
27
28 let container = std::sync::Arc::new(AtomicBitfieldContainer::new(0usize));
29 println!(
30 "lock bit: {}, data bits: {}",
31 container.read::<LockBit>(),
32 container.read::<DataBits>()
33 );
34 let thread = {
35 let container = container.clone();
36
37 std::thread::spawn(move || {
38 println!("thread 1 spawned");
39 while !container.try_acquire::<LockBit>() {}
40 container.update::<DataBits>(42);
41 println!(
42 "thread 1: set data bits to {}",
43 container.read::<DataBits>()
44 );
45 assert!(container.try_release::<LockBit>());
46 })
47 };
48
49 loop {
50 while !container.try_acquire::<LockBit>() {
51 std::thread::yield_now();
52 }
53 if container.read::<DataBits>() != 0 {
54 println!("data bits is not zero, break");
55 assert_eq!(container.read::<DataBits>(), 42);
56 assert!(container.try_release::<LockBit>());
57 break;
58 }
59
60 println!("data bits is zero, loop");
61
62 assert!(container.try_release::<LockBit>());
63 }
64 println!("{}", container.read::<DataBits>());
65 thread.join().unwrap();
66}Sourcepub fn update_synchronized<B: BitFieldTrait<T>>(&self, value: B::Type)
pub fn update_synchronized<B: BitFieldTrait<T>>(&self, value: B::Type)
Update container according to bitfield B. Does atomic store under the hood
Sourcepub fn update_conditional<B: BitFieldTrait<T>>(
&self,
value_to_be_set: B::Type,
conditional_old_value: B::Type,
) -> B::Type
pub fn update_conditional<B: BitFieldTrait<T>>( &self, value_to_be_set: B::Type, conditional_old_value: B::Type, ) -> B::Type
Conditional update of storage container according to bitfield B.
This is equivalent of CAS for bitfields.
Source§impl AtomicBitfieldContainer<u8>
impl AtomicBitfieldContainer<u8>
Sourcepub fn fetch_or<B: BitFieldTrait<u8>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<u8>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<u8>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<u8>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<u8>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<u8>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<u8>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<u8>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<u8>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<u8>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<u8>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<u8>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<u16>
impl AtomicBitfieldContainer<u16>
Sourcepub fn fetch_or<B: BitFieldTrait<u16>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<u16>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<u16>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<u16>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<u16>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<u16>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<u16>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<u16>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<u16>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<u16>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<u16>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<u16>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<u32>
impl AtomicBitfieldContainer<u32>
Sourcepub fn fetch_or<B: BitFieldTrait<u32>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<u32>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<u32>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<u32>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<u32>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<u32>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<u32>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<u32>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<u32>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<u32>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<u32>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<u32>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<u64>
impl AtomicBitfieldContainer<u64>
Sourcepub fn fetch_or<B: BitFieldTrait<u64>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<u64>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<u64>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<u64>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<u64>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<u64>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<u64>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<u64>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<u64>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<u64>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<u64>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<u64>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<i8>
impl AtomicBitfieldContainer<i8>
Sourcepub fn fetch_or<B: BitFieldTrait<i8>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<i8>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<i8>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<i8>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<i8>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<i8>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<i8>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<i8>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<i8>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<i8>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<i8>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<i8>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<i16>
impl AtomicBitfieldContainer<i16>
Sourcepub fn fetch_or<B: BitFieldTrait<i16>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<i16>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<i16>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<i16>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<i16>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<i16>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<i16>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<i16>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<i16>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<i16>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<i16>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<i16>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<i32>
impl AtomicBitfieldContainer<i32>
Sourcepub fn fetch_or<B: BitFieldTrait<i32>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<i32>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<i32>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<i32>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<i32>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<i32>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<i32>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<i32>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<i32>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<i32>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<i32>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<i32>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<i64>
impl AtomicBitfieldContainer<i64>
Sourcepub fn fetch_or<B: BitFieldTrait<i64>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<i64>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<i64>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<i64>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<i64>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<i64>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<i64>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<i64>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<i64>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<i64>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<i64>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<i64>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<usize>
impl AtomicBitfieldContainer<usize>
Sourcepub fn fetch_or<B: BitFieldTrait<usize>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<usize>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<usize>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<usize>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<usize>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<usize>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<usize>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<usize>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Examples found in repository?
7fn main() {
8 let mut storage;
9
10 storage = A::encode(true);
11 assert!(A::decode(storage));
12 storage = B::update(-1, storage);
13 assert_eq!(B::decode(storage), -1);
14 storage = B::update(2, storage);
15 assert_eq!(B::decode(storage), 2);
16 assert!(A::decode(storage));
17 assert_eq!(C::decode(storage), 0);
18 assert!(B::is_valid(7));
19 assert!(!B::is_valid(8));
20 assert!(B::is_valid(-8));
21 assert!(!B::is_valid(-9));
22
23 println!("Creating atomic bitfield storage");
24
25 type LockBit = BitField<usize, bool, 0, 1, false>;
26 type DataBits = BitField<usize, u32, { LockBit::NEXT_BIT }, 32, false>;
27
28 let container = std::sync::Arc::new(AtomicBitfieldContainer::new(0usize));
29 println!(
30 "lock bit: {}, data bits: {}",
31 container.read::<LockBit>(),
32 container.read::<DataBits>()
33 );
34 let thread = {
35 let container = container.clone();
36
37 std::thread::spawn(move || {
38 println!("thread 1 spawned");
39 while !container.try_acquire::<LockBit>() {}
40 container.update::<DataBits>(42);
41 println!(
42 "thread 1: set data bits to {}",
43 container.read::<DataBits>()
44 );
45 assert!(container.try_release::<LockBit>());
46 })
47 };
48
49 loop {
50 while !container.try_acquire::<LockBit>() {
51 std::thread::yield_now();
52 }
53 if container.read::<DataBits>() != 0 {
54 println!("data bits is not zero, break");
55 assert_eq!(container.read::<DataBits>(), 42);
56 assert!(container.try_release::<LockBit>());
57 break;
58 }
59
60 println!("data bits is zero, loop");
61
62 assert!(container.try_release::<LockBit>());
63 }
64 println!("{}", container.read::<DataBits>());
65 thread.join().unwrap();
66}Sourcepub fn try_release<B: BitFieldTrait<usize>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<usize>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Examples found in repository?
7fn main() {
8 let mut storage;
9
10 storage = A::encode(true);
11 assert!(A::decode(storage));
12 storage = B::update(-1, storage);
13 assert_eq!(B::decode(storage), -1);
14 storage = B::update(2, storage);
15 assert_eq!(B::decode(storage), 2);
16 assert!(A::decode(storage));
17 assert_eq!(C::decode(storage), 0);
18 assert!(B::is_valid(7));
19 assert!(!B::is_valid(8));
20 assert!(B::is_valid(-8));
21 assert!(!B::is_valid(-9));
22
23 println!("Creating atomic bitfield storage");
24
25 type LockBit = BitField<usize, bool, 0, 1, false>;
26 type DataBits = BitField<usize, u32, { LockBit::NEXT_BIT }, 32, false>;
27
28 let container = std::sync::Arc::new(AtomicBitfieldContainer::new(0usize));
29 println!(
30 "lock bit: {}, data bits: {}",
31 container.read::<LockBit>(),
32 container.read::<DataBits>()
33 );
34 let thread = {
35 let container = container.clone();
36
37 std::thread::spawn(move || {
38 println!("thread 1 spawned");
39 while !container.try_acquire::<LockBit>() {}
40 container.update::<DataBits>(42);
41 println!(
42 "thread 1: set data bits to {}",
43 container.read::<DataBits>()
44 );
45 assert!(container.try_release::<LockBit>());
46 })
47 };
48
49 loop {
50 while !container.try_acquire::<LockBit>() {
51 std::thread::yield_now();
52 }
53 if container.read::<DataBits>() != 0 {
54 println!("data bits is not zero, break");
55 assert_eq!(container.read::<DataBits>(), 42);
56 assert!(container.try_release::<LockBit>());
57 break;
58 }
59
60 println!("data bits is zero, loop");
61
62 assert!(container.try_release::<LockBit>());
63 }
64 println!("{}", container.read::<DataBits>());
65 thread.join().unwrap();
66}Sourcepub fn update_bool<B: BitFieldTrait<usize>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<usize>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.
Source§impl AtomicBitfieldContainer<isize>
impl AtomicBitfieldContainer<isize>
Sourcepub fn fetch_or<B: BitFieldTrait<isize>>(&self, value: B::Type)
pub fn fetch_or<B: BitFieldTrait<isize>>(&self, value: B::Type)
fetch_or operation for bitfield B
Sourcepub fn fetch_and<B: BitFieldTrait<isize>>(&self, value: B::Type)
pub fn fetch_and<B: BitFieldTrait<isize>>(&self, value: B::Type)
fetch_and operation for bitfield B
Sourcepub fn fetch_xor<B: BitFieldTrait<isize>>(&self, value: B::Type)
pub fn fetch_xor<B: BitFieldTrait<isize>>(&self, value: B::Type)
fetch_xor operation for bitfield B
Sourcepub fn try_acquire<B: BitFieldTrait<isize>>(&self) -> bool
pub fn try_acquire<B: BitFieldTrait<isize>>(&self) -> bool
Try to acquire bitfield B, can be used to implement atomic locks.
Sourcepub fn try_release<B: BitFieldTrait<isize>>(&self) -> bool
pub fn try_release<B: BitFieldTrait<isize>>(&self) -> bool
Try to release bitfield B, can be used to implement atomic locks.
Sourcepub fn update_bool<B: BitFieldTrait<isize>>(&self, value: bool, order: Ordering)
pub fn update_bool<B: BitFieldTrait<isize>>(&self, value: bool, order: Ordering)
Update storage container according to bitfield B based on boolean value,
B::Type must implement From<bool>.