From 96b014c12a67d49f1528b187bf9f0b5c66869905 Mon Sep 17 00:00:00 2001 From: George Hahn Date: Wed, 27 Nov 2019 14:10:20 -0600 Subject: [PATCH] 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 --- tokio/src/runtime/current_thread/runtime.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tokio/src/runtime/current_thread/runtime.rs b/tokio/src/runtime/current_thread/runtime.rs index e6562809b..ac490d95d 100644 --- a/tokio/src/runtime/current_thread/runtime.rs +++ b/tokio/src/runtime/current_thread/runtime.rs @@ -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 future::Executor for Handle