Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge crossbeam-channel into std::sync::mpsc #93563

Merged
merged 14 commits into from
Nov 13, 2022
Merged
Prev Previous commit
Next Next commit
remove extra spinning from mpsc::Receiver::recv
ibraheemdev committed Nov 10, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 8c17a3e7cb0717fbc849f2a8250e8f5b88a1a3c7
16 changes: 3 additions & 13 deletions library/std/src/sync/mpmc/array.rs
Original file line number Diff line number Diff line change
@@ -379,19 +379,9 @@ impl<T> Channel<T> {
pub(crate) fn recv(&self, deadline: Option<Instant>) -> Result<T, RecvTimeoutError> {
let token = &mut Token::default();
loop {
// Try receiving a message several times.
let backoff = Backoff::new();
loop {
if self.start_recv(token) {
let res = unsafe { self.read(token) };
return res.map_err(|_| RecvTimeoutError::Disconnected);
}

if backoff.is_completed() {
break;
} else {
backoff.snooze();
}
if self.start_recv(token) {
let res = unsafe { self.read(token) };
return res.map_err(|_| RecvTimeoutError::Disconnected);
}

if let Some(d) = deadline {
16 changes: 3 additions & 13 deletions library/std/src/sync/mpmc/list.rs
Original file line number Diff line number Diff line change
@@ -418,19 +418,9 @@ impl<T> Channel<T> {
pub(crate) fn recv(&self, deadline: Option<Instant>) -> Result<T, RecvTimeoutError> {
let token = &mut Token::default();
loop {
// Try receiving a message several times.
let backoff = Backoff::new();
loop {
if self.start_recv(token) {
unsafe {
return self.read(token).map_err(|_| RecvTimeoutError::Disconnected);
}
}

if backoff.is_completed() {
break;
} else {
backoff.snooze();
if self.start_recv(token) {
unsafe {
return self.read(token).map_err(|_| RecvTimeoutError::Disconnected);
}
}