Skip to content

Commit

Permalink
optimizes memory ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
campeis committed Oct 14, 2023
1 parent a75ee1a commit 4214f88
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tracking_cursor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ impl TrackingCursor {

pub(crate) fn try_advance_cursor(&self) -> Result<ReservedForCursor, ReservationErr> {
loop {
let from = self.cursor.load(Ordering::SeqCst);
let actual_target = self.target.load(Ordering::SeqCst);
let from = self.cursor.load(Ordering::Acquire);
let actual_target = self.target.load(Ordering::Relaxed);

let to = (from + 1) & self.overflow_mask;
let first_available_target = (actual_target + 1) & self.overflow_mask;
Expand All @@ -86,7 +86,7 @@ impl TrackingCursor {

if self
.cursor
.compare_exchange(from, to, Ordering::SeqCst, Ordering::SeqCst)
.compare_exchange(from, to, Ordering::Relaxed, Ordering::Relaxed)
.is_ok()
{
return Ok(ReservedForCursor {
Expand Down Expand Up @@ -124,8 +124,8 @@ impl TrackingCursor {
.compare_exchange(
reserved.from,
reserved.to,
Ordering::SeqCst,
Ordering::SeqCst,
Ordering::Release,
Ordering::Relaxed,
)
.is_ok()
{
Expand Down

0 comments on commit 4214f88

Please sign in to comment.