pub struct AtomicBool { /* private fields */ }Expand description
Atomic boolean type.
Provides easy-to-use atomic operations with automatic memory ordering selection. All methods are thread-safe and can be shared across threads.
§Memory Ordering Strategy
This type uses carefully selected default memory orderings:
-
Read operations (
load): UseAcquireordering to ensure that all writes from other threads that happened before aReleasestore are visible after this load. -
Write operations (
store): UseReleaseordering to ensure that all prior writes in this thread are visible to other threads that perform anAcquireload. -
Read-Modify-Write operations (
swap,compare_set,fetch_*): UseAcqRelordering to combine bothAcquireandReleasesemantics, ensuring proper synchronization in both directions. -
CAS failure: Use
Acquireordering on failure to observe the actual value written by another thread.
These orderings provide a balance between performance and correctness for typical concurrent programming patterns.
§Features
- Automatic memory ordering selection
- Rich set of boolean-specific operations
- Zero-cost abstraction with inline methods
- Access to underlying type via
inner()for advanced use cases
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
use std::sync::Arc;
use std::thread;
let flag = Arc::new(AtomicBool::new(false));
let flag_clone = flag.clone();
let handle = thread::spawn(move || {
flag_clone.store(true);
});
handle.join().unwrap();
assert_eq!(flag.load(), true);§Author
Haixing Hu
Implementations§
Source§impl AtomicBool
impl AtomicBool
Sourcepub const fn new(value: bool) -> Self
pub const fn new(value: bool) -> Self
Creates a new atomic boolean.
§Parameters
value- The initial value.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
assert_eq!(flag.load(), false);Examples found in repository?
18fn main() {
19 println!("=== Atomic Boolean Flag Example ===\n");
20
21 // Example 1: Simple flag
22 println!("1. Simple Flag:");
23 let flag = AtomicBool::new(false);
24 println!(" Initial value: {}", flag.load());
25
26 flag.store(true);
27 println!(" After set(true): {}", flag.load());
28
29 flag.fetch_not();
30 println!(" After negate: {}", flag.load());
31
32 // Example 2: One-time initialization
33 println!("\n2. One-time Initialization:");
34 let initialized = Arc::new(AtomicBool::new(false));
35 let mut handles = vec![];
36
37 for i in 0..5 {
38 let initialized = initialized.clone();
39 let handle = thread::spawn(move || {
40 if initialized.set_if_false(true).is_ok() {
41 println!(" Thread {} performed initialization", i);
42 thread::sleep(Duration::from_millis(100));
43 } else {
44 println!(" Thread {} skipped (already initialized)", i);
45 }
46 });
47 handles.push(handle);
48 }
49
50 for handle in handles {
51 handle.join().unwrap();
52 }
53
54 println!(" Final state: initialized = {}", initialized.load());
55
56 // Example 3: Producer-Consumer signaling
57 println!("\n3. Producer-Consumer Signaling:");
58 let ready = Arc::new(AtomicBool::new(false));
59 let data = Arc::new(AtomicBool::new(false));
60
61 let ready_clone = ready.clone();
62 let data_clone = data.clone();
63
64 // Producer thread
65 let producer = thread::spawn(move || {
66 println!(" Producer: preparing data...");
67 thread::sleep(Duration::from_millis(100));
68 data_clone.store(true);
69 ready_clone.store(true);
70 println!(" Producer: data ready!");
71 });
72
73 // Consumer thread
74 let consumer = thread::spawn(move || {
75 println!(" Consumer: waiting for data...");
76 while !ready.load() {
77 thread::yield_now();
78 }
79 println!(" Consumer: received data = {}", data.load());
80 });
81
82 producer.join().unwrap();
83 consumer.join().unwrap();
84
85 // Example 4: Toggle operations
86 println!("\n4. Toggle Operations:");
87 let flag = Arc::new(AtomicBool::new(false));
88 let mut handles = vec![];
89
90 for i in 0..10 {
91 let flag = flag.clone();
92 let handle = thread::spawn(move || {
93 for _ in 0..10 {
94 flag.fetch_not();
95 }
96 println!(" Thread {} completed 10 toggles", i);
97 });
98 handles.push(handle);
99 }
100
101 for handle in handles {
102 handle.join().unwrap();
103 }
104
105 println!(" Final state: {} (after 100 toggles)", flag.load());
106
107 println!("\n=== Example completed ===");
108}Sourcepub fn load(&self) -> bool
pub fn load(&self) -> bool
Gets the current value.
§Memory Ordering
Uses Acquire ordering. This ensures that:
- All writes from other threads that happened before a
Releasestore are visible after this load. - Forms a synchronizes-with relationship with
Releasestores. - Prevents reordering of subsequent reads/writes before this load.
This is appropriate for reading shared state that may have been modified by other threads.
§Returns
The current value.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(true);
assert_eq!(flag.load(), true);Examples found in repository?
18fn main() {
19 println!("=== Atomic Boolean Flag Example ===\n");
20
21 // Example 1: Simple flag
22 println!("1. Simple Flag:");
23 let flag = AtomicBool::new(false);
24 println!(" Initial value: {}", flag.load());
25
26 flag.store(true);
27 println!(" After set(true): {}", flag.load());
28
29 flag.fetch_not();
30 println!(" After negate: {}", flag.load());
31
32 // Example 2: One-time initialization
33 println!("\n2. One-time Initialization:");
34 let initialized = Arc::new(AtomicBool::new(false));
35 let mut handles = vec![];
36
37 for i in 0..5 {
38 let initialized = initialized.clone();
39 let handle = thread::spawn(move || {
40 if initialized.set_if_false(true).is_ok() {
41 println!(" Thread {} performed initialization", i);
42 thread::sleep(Duration::from_millis(100));
43 } else {
44 println!(" Thread {} skipped (already initialized)", i);
45 }
46 });
47 handles.push(handle);
48 }
49
50 for handle in handles {
51 handle.join().unwrap();
52 }
53
54 println!(" Final state: initialized = {}", initialized.load());
55
56 // Example 3: Producer-Consumer signaling
57 println!("\n3. Producer-Consumer Signaling:");
58 let ready = Arc::new(AtomicBool::new(false));
59 let data = Arc::new(AtomicBool::new(false));
60
61 let ready_clone = ready.clone();
62 let data_clone = data.clone();
63
64 // Producer thread
65 let producer = thread::spawn(move || {
66 println!(" Producer: preparing data...");
67 thread::sleep(Duration::from_millis(100));
68 data_clone.store(true);
69 ready_clone.store(true);
70 println!(" Producer: data ready!");
71 });
72
73 // Consumer thread
74 let consumer = thread::spawn(move || {
75 println!(" Consumer: waiting for data...");
76 while !ready.load() {
77 thread::yield_now();
78 }
79 println!(" Consumer: received data = {}", data.load());
80 });
81
82 producer.join().unwrap();
83 consumer.join().unwrap();
84
85 // Example 4: Toggle operations
86 println!("\n4. Toggle Operations:");
87 let flag = Arc::new(AtomicBool::new(false));
88 let mut handles = vec![];
89
90 for i in 0..10 {
91 let flag = flag.clone();
92 let handle = thread::spawn(move || {
93 for _ in 0..10 {
94 flag.fetch_not();
95 }
96 println!(" Thread {} completed 10 toggles", i);
97 });
98 handles.push(handle);
99 }
100
101 for handle in handles {
102 handle.join().unwrap();
103 }
104
105 println!(" Final state: {} (after 100 toggles)", flag.load());
106
107 println!("\n=== Example completed ===");
108}Sourcepub fn store(&self, value: bool)
pub fn store(&self, value: bool)
Sets a new value.
§Memory Ordering
Uses Release ordering. This ensures that:
- All prior writes in this thread are visible to other threads that
perform an
Acquireload. - Forms a synchronizes-with relationship with
Acquireloads. - Prevents reordering of prior reads/writes after this store.
This is appropriate for publishing shared state to other threads.
§Parameters
value- The new value to set.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
flag.store(true);
assert_eq!(flag.load(), true);Examples found in repository?
18fn main() {
19 println!("=== Atomic Boolean Flag Example ===\n");
20
21 // Example 1: Simple flag
22 println!("1. Simple Flag:");
23 let flag = AtomicBool::new(false);
24 println!(" Initial value: {}", flag.load());
25
26 flag.store(true);
27 println!(" After set(true): {}", flag.load());
28
29 flag.fetch_not();
30 println!(" After negate: {}", flag.load());
31
32 // Example 2: One-time initialization
33 println!("\n2. One-time Initialization:");
34 let initialized = Arc::new(AtomicBool::new(false));
35 let mut handles = vec![];
36
37 for i in 0..5 {
38 let initialized = initialized.clone();
39 let handle = thread::spawn(move || {
40 if initialized.set_if_false(true).is_ok() {
41 println!(" Thread {} performed initialization", i);
42 thread::sleep(Duration::from_millis(100));
43 } else {
44 println!(" Thread {} skipped (already initialized)", i);
45 }
46 });
47 handles.push(handle);
48 }
49
50 for handle in handles {
51 handle.join().unwrap();
52 }
53
54 println!(" Final state: initialized = {}", initialized.load());
55
56 // Example 3: Producer-Consumer signaling
57 println!("\n3. Producer-Consumer Signaling:");
58 let ready = Arc::new(AtomicBool::new(false));
59 let data = Arc::new(AtomicBool::new(false));
60
61 let ready_clone = ready.clone();
62 let data_clone = data.clone();
63
64 // Producer thread
65 let producer = thread::spawn(move || {
66 println!(" Producer: preparing data...");
67 thread::sleep(Duration::from_millis(100));
68 data_clone.store(true);
69 ready_clone.store(true);
70 println!(" Producer: data ready!");
71 });
72
73 // Consumer thread
74 let consumer = thread::spawn(move || {
75 println!(" Consumer: waiting for data...");
76 while !ready.load() {
77 thread::yield_now();
78 }
79 println!(" Consumer: received data = {}", data.load());
80 });
81
82 producer.join().unwrap();
83 consumer.join().unwrap();
84
85 // Example 4: Toggle operations
86 println!("\n4. Toggle Operations:");
87 let flag = Arc::new(AtomicBool::new(false));
88 let mut handles = vec![];
89
90 for i in 0..10 {
91 let flag = flag.clone();
92 let handle = thread::spawn(move || {
93 for _ in 0..10 {
94 flag.fetch_not();
95 }
96 println!(" Thread {} completed 10 toggles", i);
97 });
98 handles.push(handle);
99 }
100
101 for handle in handles {
102 handle.join().unwrap();
103 }
104
105 println!(" Final state: {} (after 100 toggles)", flag.load());
106
107 println!("\n=== Example completed ===");
108}Sourcepub fn swap(&self, value: bool) -> bool
pub fn swap(&self, value: bool) -> bool
Swaps the current value with a new value, returning the old value.
§Memory Ordering
Uses AcqRel ordering. This ensures that:
- Acquire: All writes from other threads that happened before
their
Releaseoperations are visible after this operation. - Release: All prior writes in this thread are visible to other
threads that perform subsequent
Acquireoperations.
This provides full synchronization for read-modify-write operations.
§Parameters
value- The new value to swap in.
§Returns
The old value.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
let old = flag.swap(true);
assert_eq!(old, false);
assert_eq!(flag.load(), true);Sourcepub fn compare_set(&self, current: bool, new: bool) -> Result<(), bool>
pub fn compare_set(&self, current: bool, new: bool) -> Result<(), bool>
Compares and sets the value atomically.
If the current value equals current, sets it to new and returns
Ok(()). Otherwise, returns Err(actual) where actual is the
current value.
§Memory Ordering
- Success: Uses
AcqRelordering to ensure full synchronization when the exchange succeeds. - Failure: Uses
Acquireordering to observe the actual value written by another thread.
This pattern is essential for implementing lock-free algorithms where you need to retry based on the observed value.
§Parameters
current- The expected current value.new- The new value to set if current matches.
§Returns
Ok(()) on success, or Err(actual) on failure.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
assert!(flag.compare_set(false, true).is_ok());
assert_eq!(flag.load(), true);
// Fails because current value is true, not false
assert!(flag.compare_set(false, false).is_err());Sourcepub fn compare_set_weak(&self, current: bool, new: bool) -> Result<(), bool>
pub fn compare_set_weak(&self, current: bool, new: bool) -> Result<(), bool>
Weak version of compare-and-set.
May spuriously fail even when the comparison succeeds. Should be used in a loop.
Uses AcqRel ordering on success and Acquire ordering on failure.
§Parameters
current- The expected current value.new- The new value to set if current matches.
§Returns
Ok(()) on success, or Err(actual) on failure.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
let mut current = flag.load();
loop {
match flag.compare_set_weak(current, true) {
Ok(_) => break,
Err(actual) => current = actual,
}
}
assert_eq!(flag.load(), true);Sourcepub fn compare_and_exchange(&self, current: bool, new: bool) -> bool
pub fn compare_and_exchange(&self, current: bool, new: bool) -> bool
Compares and exchanges the value atomically, returning the previous value.
If the current value equals current, sets it to new and returns
the old value. Otherwise, returns the actual current value.
Uses AcqRel ordering on success and Acquire ordering on failure.
§Parameters
current- The expected current value.new- The new value to set if current matches.
§Returns
The value before the operation.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
let prev = flag.compare_and_exchange(false, true);
assert_eq!(prev, false);
assert_eq!(flag.load(), true);Sourcepub fn compare_and_exchange_weak(&self, current: bool, new: bool) -> bool
pub fn compare_and_exchange_weak(&self, current: bool, new: bool) -> bool
Weak version of compare-and-exchange.
May spuriously fail even when the comparison succeeds. Should be used in a loop.
Uses AcqRel ordering on success and Acquire ordering on failure.
§Parameters
current- The expected current value.new- The new value to set if current matches.
§Returns
The value before the operation.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
let mut current = flag.load();
loop {
let prev = flag.compare_and_exchange_weak(current, true);
if prev == current {
break;
}
current = prev;
}
assert_eq!(flag.load(), true);Sourcepub fn fetch_set(&self) -> bool
pub fn fetch_set(&self) -> bool
Atomically sets the value to true, returning the old value.
§Memory Ordering
Uses AcqRel ordering (via swap). This ensures full
synchronization with other threads for this read-modify-write
operation.
§Returns
The old value before setting to true.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
let old = flag.fetch_set();
assert_eq!(old, false);
assert_eq!(flag.load(), true);Sourcepub fn fetch_clear(&self) -> bool
pub fn fetch_clear(&self) -> bool
Atomically sets the value to false, returning the old value.
§Memory Ordering
Uses AcqRel ordering (via swap). This ensures full
synchronization with other threads for this read-modify-write
operation.
§Returns
The old value before setting to false.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(true);
let old = flag.fetch_clear();
assert_eq!(old, true);
assert_eq!(flag.load(), false);Sourcepub fn fetch_not(&self) -> bool
pub fn fetch_not(&self) -> bool
Atomically negates the value, returning the old value.
§Memory Ordering
Uses AcqRel ordering. This ensures full synchronization with other
threads for this read-modify-write operation.
§Returns
The old value before negation.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
assert_eq!(flag.fetch_not(), false);
assert_eq!(flag.load(), true);
assert_eq!(flag.fetch_not(), true);
assert_eq!(flag.load(), false);Examples found in repository?
18fn main() {
19 println!("=== Atomic Boolean Flag Example ===\n");
20
21 // Example 1: Simple flag
22 println!("1. Simple Flag:");
23 let flag = AtomicBool::new(false);
24 println!(" Initial value: {}", flag.load());
25
26 flag.store(true);
27 println!(" After set(true): {}", flag.load());
28
29 flag.fetch_not();
30 println!(" After negate: {}", flag.load());
31
32 // Example 2: One-time initialization
33 println!("\n2. One-time Initialization:");
34 let initialized = Arc::new(AtomicBool::new(false));
35 let mut handles = vec![];
36
37 for i in 0..5 {
38 let initialized = initialized.clone();
39 let handle = thread::spawn(move || {
40 if initialized.set_if_false(true).is_ok() {
41 println!(" Thread {} performed initialization", i);
42 thread::sleep(Duration::from_millis(100));
43 } else {
44 println!(" Thread {} skipped (already initialized)", i);
45 }
46 });
47 handles.push(handle);
48 }
49
50 for handle in handles {
51 handle.join().unwrap();
52 }
53
54 println!(" Final state: initialized = {}", initialized.load());
55
56 // Example 3: Producer-Consumer signaling
57 println!("\n3. Producer-Consumer Signaling:");
58 let ready = Arc::new(AtomicBool::new(false));
59 let data = Arc::new(AtomicBool::new(false));
60
61 let ready_clone = ready.clone();
62 let data_clone = data.clone();
63
64 // Producer thread
65 let producer = thread::spawn(move || {
66 println!(" Producer: preparing data...");
67 thread::sleep(Duration::from_millis(100));
68 data_clone.store(true);
69 ready_clone.store(true);
70 println!(" Producer: data ready!");
71 });
72
73 // Consumer thread
74 let consumer = thread::spawn(move || {
75 println!(" Consumer: waiting for data...");
76 while !ready.load() {
77 thread::yield_now();
78 }
79 println!(" Consumer: received data = {}", data.load());
80 });
81
82 producer.join().unwrap();
83 consumer.join().unwrap();
84
85 // Example 4: Toggle operations
86 println!("\n4. Toggle Operations:");
87 let flag = Arc::new(AtomicBool::new(false));
88 let mut handles = vec![];
89
90 for i in 0..10 {
91 let flag = flag.clone();
92 let handle = thread::spawn(move || {
93 for _ in 0..10 {
94 flag.fetch_not();
95 }
96 println!(" Thread {} completed 10 toggles", i);
97 });
98 handles.push(handle);
99 }
100
101 for handle in handles {
102 handle.join().unwrap();
103 }
104
105 println!(" Final state: {} (after 100 toggles)", flag.load());
106
107 println!("\n=== Example completed ===");
108}Sourcepub fn fetch_and(&self, value: bool) -> bool
pub fn fetch_and(&self, value: bool) -> bool
Atomically performs logical AND, returning the old value.
§Memory Ordering
Uses AcqRel ordering. This ensures full synchronization with other
threads for this read-modify-write operation, which is necessary
because the operation depends on the current value.
§Parameters
value- The value to AND with.
§Returns
The old value before the operation.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(true);
assert_eq!(flag.fetch_and(false), true);
assert_eq!(flag.load(), false);Sourcepub fn fetch_or(&self, value: bool) -> bool
pub fn fetch_or(&self, value: bool) -> bool
Atomically performs logical OR, returning the old value.
§Memory Ordering
Uses AcqRel ordering. This ensures full synchronization with other
threads for this read-modify-write operation, which is necessary
because the operation depends on the current value.
§Parameters
value- The value to OR with.
§Returns
The old value before the operation.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
assert_eq!(flag.fetch_or(true), false);
assert_eq!(flag.load(), true);Sourcepub fn fetch_xor(&self, value: bool) -> bool
pub fn fetch_xor(&self, value: bool) -> bool
Atomically performs logical XOR, returning the old value.
§Memory Ordering
Uses AcqRel ordering. This ensures full synchronization with other
threads for this read-modify-write operation, which is necessary
because the operation depends on the current value.
§Parameters
value- The value to XOR with.
§Returns
The old value before the operation.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
assert_eq!(flag.fetch_xor(true), false);
assert_eq!(flag.load(), true);Sourcepub fn set_if_false(&self, new: bool) -> Result<(), bool>
pub fn set_if_false(&self, new: bool) -> Result<(), bool>
Conditionally sets the value if it is currently false.
Uses AcqRel ordering on success and Acquire ordering on failure.
§Parameters
new- The new value to set if current isfalse.
§Returns
Ok(()) if the value was false and has been set to new,
Err(true) if the value was already true.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(false);
assert!(flag.set_if_false(true).is_ok());
assert_eq!(flag.load(), true);
// Second attempt fails
assert!(flag.set_if_false(true).is_err());Examples found in repository?
18fn main() {
19 println!("=== Atomic Boolean Flag Example ===\n");
20
21 // Example 1: Simple flag
22 println!("1. Simple Flag:");
23 let flag = AtomicBool::new(false);
24 println!(" Initial value: {}", flag.load());
25
26 flag.store(true);
27 println!(" After set(true): {}", flag.load());
28
29 flag.fetch_not();
30 println!(" After negate: {}", flag.load());
31
32 // Example 2: One-time initialization
33 println!("\n2. One-time Initialization:");
34 let initialized = Arc::new(AtomicBool::new(false));
35 let mut handles = vec![];
36
37 for i in 0..5 {
38 let initialized = initialized.clone();
39 let handle = thread::spawn(move || {
40 if initialized.set_if_false(true).is_ok() {
41 println!(" Thread {} performed initialization", i);
42 thread::sleep(Duration::from_millis(100));
43 } else {
44 println!(" Thread {} skipped (already initialized)", i);
45 }
46 });
47 handles.push(handle);
48 }
49
50 for handle in handles {
51 handle.join().unwrap();
52 }
53
54 println!(" Final state: initialized = {}", initialized.load());
55
56 // Example 3: Producer-Consumer signaling
57 println!("\n3. Producer-Consumer Signaling:");
58 let ready = Arc::new(AtomicBool::new(false));
59 let data = Arc::new(AtomicBool::new(false));
60
61 let ready_clone = ready.clone();
62 let data_clone = data.clone();
63
64 // Producer thread
65 let producer = thread::spawn(move || {
66 println!(" Producer: preparing data...");
67 thread::sleep(Duration::from_millis(100));
68 data_clone.store(true);
69 ready_clone.store(true);
70 println!(" Producer: data ready!");
71 });
72
73 // Consumer thread
74 let consumer = thread::spawn(move || {
75 println!(" Consumer: waiting for data...");
76 while !ready.load() {
77 thread::yield_now();
78 }
79 println!(" Consumer: received data = {}", data.load());
80 });
81
82 producer.join().unwrap();
83 consumer.join().unwrap();
84
85 // Example 4: Toggle operations
86 println!("\n4. Toggle Operations:");
87 let flag = Arc::new(AtomicBool::new(false));
88 let mut handles = vec![];
89
90 for i in 0..10 {
91 let flag = flag.clone();
92 let handle = thread::spawn(move || {
93 for _ in 0..10 {
94 flag.fetch_not();
95 }
96 println!(" Thread {} completed 10 toggles", i);
97 });
98 handles.push(handle);
99 }
100
101 for handle in handles {
102 handle.join().unwrap();
103 }
104
105 println!(" Final state: {} (after 100 toggles)", flag.load());
106
107 println!("\n=== Example completed ===");
108}Sourcepub fn set_if_true(&self, new: bool) -> Result<(), bool>
pub fn set_if_true(&self, new: bool) -> Result<(), bool>
Conditionally sets the value if it is currently true.
Uses AcqRel ordering on success and Acquire ordering on failure.
§Parameters
new- The new value to set if current istrue.
§Returns
Ok(()) if the value was true and has been set to new,
Err(false) if the value was already false.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
let flag = AtomicBool::new(true);
assert!(flag.set_if_true(false).is_ok());
assert_eq!(flag.load(), false);
// Second attempt fails
assert!(flag.set_if_true(false).is_err());Sourcepub fn inner(&self) -> &StdAtomicBool
pub fn inner(&self) -> &StdAtomicBool
Gets a reference to the underlying standard library atomic type.
This allows direct access to the standard library’s atomic operations for advanced use cases that require fine-grained control over memory ordering.
§Memory Ordering
When using the returned reference, you have full control over memory ordering. Choose the appropriate ordering based on your specific synchronization requirements.
§Returns
A reference to the underlying std::sync::atomic::AtomicBool.
§Example
use prism3_rust_concurrent::atomic::AtomicBool;
use std::sync::atomic::Ordering;
let flag = AtomicBool::new(false);
flag.inner().store(true, Ordering::Relaxed);
assert_eq!(flag.inner().load(Ordering::Relaxed), true);