Skip to content

Commit

Permalink
disable new feature for loom
Browse files Browse the repository at this point in the history
  • Loading branch information
wenym1 committed May 14, 2024
1 parent b7c5c8c commit 605315a
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions tokio/src/sync/oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,20 +629,29 @@ impl<T> Sender<T> {

#[rustversion::since(1.70)]
fn consume_inner<T>(inner: Arc<Inner<T>>) -> Result<(), T> {
if let Some(inner) = Arc::into_inner(inner) {
if let Some(t) = inner.value.with_mut(|ptr| unsafe {
// SAFETY: we have successfully returned with `Some`, which means we are the
// only accessor to `ptr`.
//
// Note: value can be `None` even though we have previously set it as `Some`,
// because the value may have been consumed by receiver before we reach here.
(*ptr).take()
}) {
Err(t)
#[cfg(not(loom))]
{
if let Some(inner) = Arc::into_inner(inner) {
if let Some(t) = inner.value.with_mut(|ptr| unsafe {
// SAFETY: we have successfully returned with `Some`, which means we are the
// only accessor to `ptr`.
//
// Note: value can be `None` even though we have previously set it as `Some`,
// because the value may have been consumed by receiver before we reach here.
(*ptr).take()
}) {
Err(t)
} else {
Ok(())
}
} else {
Ok(())
}
} else {
}

#[cfg(loom)]
{
// The `loom::sync::Arc` does not implement `into_inner` yet.
Ok(())
}
}
Expand Down

0 comments on commit 605315a

Please sign in to comment.