Skip to content

Commit

Permalink
rt: add missing Send bound (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Nov 2, 2020
1 parent ae4e8d7 commit 20a2b9e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tokio/Cargo.toml
Expand Up @@ -98,7 +98,7 @@ bytes = { version = "0.6.0", optional = true }
futures-core = { version = "0.3.0", optional = true }
lazy_static = { version = "1.0.2", optional = true }
memchr = { version = "2.2", optional = true }
mio = { version = "0.7.3", optional = true }
mio = { version = "0.7.5", optional = true }
num_cpus = { version = "1.8.0", optional = true }
parking_lot = { version = "0.11.0", optional = true } # Not in full
slab = { version = "0.4.1", optional = true }
Expand Down Expand Up @@ -134,4 +134,4 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
features = ["full"]
features = ["full"]
2 changes: 2 additions & 0 deletions tokio/src/runtime/blocking/pool.rs
Expand Up @@ -70,6 +70,7 @@ const KEEP_ALIVE: Duration = Duration::from_secs(10);
pub(crate) fn spawn_blocking<F, R>(func: F) -> JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
let rt = context::current().expect("not currently running on the Tokio runtime.");
rt.spawn_blocking(func)
Expand All @@ -79,6 +80,7 @@ where
pub(crate) fn try_spawn_blocking<F, R>(func: F) -> Result<(), ()>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
let rt = context::current().expect("not currently running on the Tokio runtime.");

Expand Down
3 changes: 2 additions & 1 deletion tokio/src/runtime/blocking/task.rs
Expand Up @@ -19,7 +19,8 @@ impl<T> Unpin for BlockingTask<T> {}

impl<T, R> Future for BlockingTask<T>
where
T: FnOnce() -> R,
T: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
type Output = R;

Expand Down
1 change: 1 addition & 0 deletions tokio/src/runtime/handle.rs
Expand Up @@ -45,6 +45,7 @@ impl Handle {
pub(crate) fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
#[cfg(feature = "tracing")]
let func = {
Expand Down
1 change: 1 addition & 0 deletions tokio/src/runtime/mod.rs
Expand Up @@ -392,6 +392,7 @@ cfg_rt! {
pub fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
self.handle.spawn_blocking(func)
}
Expand Down

0 comments on commit 20a2b9e

Please sign in to comment.