Skip to content

Commit

Permalink
Remove optimistic spinning from Context::wait_until
Browse files Browse the repository at this point in the history
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
  • Loading branch information
taiki-e and ibraheemdev committed Dec 15, 2024
1 parent a92f6c4 commit 8144fbb
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions crossbeam-channel/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,6 @@ impl Context {
/// If the deadline is reached, `Selected::Aborted` will be selected.
#[inline]
pub fn wait_until(&self, deadline: Option<Instant>) -> Selected {
// Spin for a short time, waiting until an operation is selected.
let backoff = Backoff::new();
loop {
let sel = Selected::from(self.inner.select.load(Ordering::Acquire));
if sel != Selected::Waiting {
return sel;
}

if backoff.is_completed() {
break;
} else {
backoff.snooze();
}
}

loop {
// Check whether an operation has been selected.
let sel = Selected::from(self.inner.select.load(Ordering::Acquire));
Expand Down

0 comments on commit 8144fbb

Please sign in to comment.