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 Sep 28, 2023
1 parent 081b807 commit 15d9243
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 15d9243

Please sign in to comment.