Skip to content

Commit

Permalink
Make pinning actually reentrant
Browse files Browse the repository at this point in the history
  • Loading branch information
aturon committed Aug 21, 2015
1 parent ac8dfd5 commit 24f09ce
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mem/epoch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ static EPOCH: EpochState = EpochState::new();

impl Participant {
fn enter(&self) {
self.in_critical.store(self.in_critical.load(Relaxed) + 1, Relaxed);
let new_count = self.in_critical.load(Relaxed) + 1;
self.in_critical.store(new_count, Relaxed);
if new_count > 1 { return }

atomic::fence(SeqCst);

let global_epoch = EPOCH.epoch.load(Relaxed);
Expand Down Expand Up @@ -179,7 +182,10 @@ impl Participant {
}

fn exit(&self) {
self.in_critical.store(self.in_critical.load(Relaxed) - 1, Release);
let new_count = self.in_critical.load(Relaxed) - 1;
self.in_critical.store(
new_count,
if new_count > 1 { Relaxed } else { Release });
}

unsafe fn reclaim<T>(&self, data: *mut T) {
Expand Down

0 comments on commit 24f09ce

Please sign in to comment.