Skip to content

Commit 569baaf

Browse files
authored
perf: optimize memory orderings in Flag::flip (#14)
1 parent c8b6430 commit 569baaf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/flag.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ macro_rules! impl_flag {
4040

4141
/// Flip the current value and return the new value
4242
pub fn flip(&self) -> bool {
43-
let mut current = self.get();
43+
let mut current = self.0.load(Ordering::Relaxed);
4444
loop {
4545
let new = !current;
4646
match self.0.compare_exchange_weak(
4747
current,
4848
new,
4949
Ordering::AcqRel,
50-
Ordering::Acquire,
50+
Ordering::Relaxed,
5151
) {
5252
Ok(_) => return new,
5353
Err(previous) => current = previous,

0 commit comments

Comments
 (0)