Skip to content

Commit

Permalink
Backoff: Increase step until YIELD_LIMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 11, 2023
1 parent 6faf1fe commit 17df6a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crossbeam-utils/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Backoff {
atomic::spin_loop_hint();
}

if self.step.get() <= SPIN_LIMIT {
if self.step.get() <= YIELD_LIMIT {
self.step.set(self.step.get() + 1);
}
}
Expand Down
19 changes: 19 additions & 0 deletions crossbeam-utils/tests/backoff.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crossbeam_utils::Backoff;

#[test]
fn is_completed() {
let b = Backoff::new();
loop {
b.spin();
if b.is_completed() {
break;
}
}
let b = Backoff::new();
loop {
b.snooze();
if b.is_completed() {
break;
}
}
}

0 comments on commit 17df6a9

Please sign in to comment.