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 May 16, 2023
1 parent a3cad6d commit a378424
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 a378424

Please sign in to comment.