Skip to content

Commit

Permalink
chore: update async_send_sync test (#3943)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Jul 12, 2021
1 parent 6610ba9 commit 7a11cfd
Show file tree
Hide file tree
Showing 2 changed files with 565 additions and 276 deletions.
10 changes: 8 additions & 2 deletions tokio/src/task/task_local.rs
Expand Up @@ -2,6 +2,7 @@ use pin_project_lite::pin_project;
use std::cell::RefCell;
use std::error::Error;
use std::future::Future;
use std::marker::PhantomPinned;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{fmt, thread};
Expand Down Expand Up @@ -123,6 +124,7 @@ impl<T: 'static> LocalKey<T> {
local: &self,
slot: Some(value),
future: f,
_pinned: PhantomPinned,
}
}

Expand All @@ -147,12 +149,14 @@ impl<T: 'static> LocalKey<T> {
where
F: FnOnce() -> R,
{
let mut scope = TaskLocalFuture {
let scope = TaskLocalFuture {
local: &self,
slot: Some(value),
future: (),
_pinned: PhantomPinned,
};
Pin::new(&mut scope).with_task(|_| f())
crate::pin!(scope);
scope.with_task(|_| f())
}

/// Accesses the current task-local and runs the provided closure.
Expand Down Expand Up @@ -234,6 +238,8 @@ pin_project! {
slot: Option<T>,
#[pin]
future: F,
#[pin]
_pinned: PhantomPinned,
}
}

Expand Down

1 comment on commit 7a11cfd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'sync_mpsc'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 7a11cfd Previous: 3fd88da Ratio
send_large 66298 ns/iter (± 2691) 24881 ns/iter (± 259) 2.66

This comment was automatically generated by workflow using github-action-benchmark.

CC: @tokio-rs/maintainers

Please sign in to comment.