Skip to content

Commit

Permalink
Relax ordering of transition
Browse files Browse the repository at this point in the history
The first ordering of no operation relies on SeqCst semantics.
All works with Acquire/Release semantics, so there is no reason to use the SeqCst ordering.

The second ordering argument is for the failure, in which case we don't read any data,
and therefore don't need any synchronization.
  • Loading branch information
sosthene-nitrokey committed Jun 14, 2024
1 parent 0a75cda commit b1dee74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl<Rq, Rp> Channel<Rq, Rp> {

fn transition(&self, from: State, to: State) -> bool {
self.state
.compare_exchange(from as u8, to as u8, Ordering::SeqCst, Ordering::SeqCst)
.compare_exchange(from as u8, to as u8, Ordering::AcqRel, Ordering::Relaxed)
.is_ok()
}
}
Expand Down

0 comments on commit b1dee74

Please sign in to comment.