summaryrefslogtreecommitdiffstats
path: root/tokio/src
diff options
context:
space:
mode:
authorAlice Ryhl <alice@ryhl.io>2020-11-03 00:30:07 +0100
committerGitHub <noreply@github.com>2020-11-02 15:30:07 -0800
commit20a2b9e26316e704d16c62a28dfb74a505b92b25 (patch)
treee079440872af05deb22716e221aca85b4be3f8b6 /tokio/src
parentae4e8d7ad1afbfb1a5e8a60a307a7981b6f508dc (diff)
rt: add missing Send bound (#3089)
Diffstat (limited to 'tokio/src')
-rw-r--r--tokio/src/runtime/blocking/pool.rs2
-rw-r--r--tokio/src/runtime/blocking/task.rs3
-rw-r--r--tokio/src/runtime/handle.rs1
-rw-r--r--tokio/src/runtime/mod.rs1
4 files changed, 6 insertions, 1 deletions
diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs
index 2967a109..6b9fb1bf 100644
--- a/tokio/src/runtime/blocking/pool.rs
+++ b/tokio/src/runtime/blocking/pool.rs
@@ -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)
@@ -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.");
diff --git a/tokio/src/runtime/blocking/task.rs b/tokio/src/runtime/blocking/task.rs
index a521af46..ee2d8d6d 100644
--- a/tokio/src/runtime/blocking/task.rs
+++ b/tokio/src/runtime/blocking/task.rs
@@ -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;
diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs
index c9ffd5cd..72b9c065 100644
--- a/tokio/src/runtime/handle.rs
+++ b/tokio/src/runtime/handle.rs
@@ -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 = {
diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs
index c76f5cf6..f85344db 100644
--- a/tokio/src/runtime/mod.rs
+++ b/tokio/src/runtime/mod.rs
@@ -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)
}