Allow access to CurrentThread executor handle (#1809)

## Motivation

The `CurrentThread` runtime's `Handle` is different than the
`CurrentThread` executor's `Handle`. This causes interoperability issues
with custom runtimes that build on the `CurrentThread` executor.

Actix-rt offers a concrete example of the issue: [`System::run_in_executor`][1]
requires a `CurrentThread` executor handle - the change in this PR
allows a `CurrentThread` runtime to be used here.

## Solution

This PR adds `fn into_inner(self)` on the runtime `Handle` that consumes
it and returns the underlying `CurrentThread` executor's `Handle`.

[1]: https://docs.rs/actix-rt/0.2.6/actix_rt/struct.System.html#method.run_in_executor
This commit is contained in:
George Hahn
2019-11-27 12:10:20 -08:00
committed by Eliza Weisman
parent b0a90d88cd
commit 96b014c12a
@@ -55,6 +55,11 @@ impl Handle {
pub fn status(&self) -> Result<(), tokio_executor::SpawnError> {
self.0.status()
}
/// Retrieve inner `CurrentThread` executor handle
pub fn into_inner(self) -> ExecutorHandle {
self.0
}
}
impl<T> future::Executor<T> for Handle