diff options
author | Eliza Weisman <eliza@buoyant.io> | 2019-12-02 16:43:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 16:43:33 -0800 |
commit | 07451f8b94a8b867696ddc1c6b546774fe1e06e4 (patch) | |
tree | 2eb2572ffa09124258562ba9b209c144f64501bf /tokio/src/task | |
parent | e87df0557da4e8f70f3939c77e84acddc25652ba (diff) |
task: relax 'static bound in `LocalSet::block_on` (#1882)
## Motivation
Currently, `tokio::task::LocalSet`'s `block_on` method requires the
future to live for the 'static lifetime. However, this bound is not
required — the future is wrapped in a `LocalFuture`, and then passed
into `Runtime::block_on`, which does _not_ require a `'static` future.
This came up while updating `tokio-compat` to work with version 0.2. To
mimic the behavior of `tokio` 0.1's `current_thread::Runtime::run`, we
want to be able to have a runtime block on the `recv` future from an
mpsc channel indicating when the runtime is idle. To support `!Send`
futures, as the old `current_thread::Runtime` did, we must do so inside
of a `LocalSet`. However, with the current bounds, we cannot await an
`mpsc::Receiver`'s `recv` future inside the `LocalSet::block_on` call.
## Solution
This branch removes the unnecessary `'static` bound.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Diffstat (limited to 'tokio/src/task')
-rw-r--r-- | tokio/src/task/local.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs index 7f29e3d1..f81522c9 100644 --- a/tokio/src/task/local.rs +++ b/tokio/src/task/local.rs @@ -303,8 +303,7 @@ impl LocalSet { /// [`spawn_blocking`]: ../blocking/fn.spawn_blocking.html pub fn block_on<F>(&self, rt: &mut crate::runtime::Runtime, future: F) -> F::Output where - F: Future + 'static, - F::Output: 'static, + F: Future, { let scheduler = self.scheduler.clone(); self.scheduler |