From 5c852d5b829c571157f262c2c64b6ea907b75f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 4 Dec 2020 09:42:23 +0100 Subject: [PATCH] tokio: adapt to 1.0 runtime changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit enter() now returns a guard, and the builder got revamped to make the choice between MT and current thread explicit. Signed-off-by: Fabian Grünbichler --- src/tools/runtime.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/runtime.rs b/src/tools/runtime.rs index 1953e202..46564e76 100644 --- a/src/tools/runtime.rs +++ b/src/tools/runtime.rs @@ -84,8 +84,7 @@ pub fn get_runtime_with_builder runtime::Builder>(get_builder: F) -> pub fn get_runtime() -> Arc { get_runtime_with_builder(|| { - let mut builder = runtime::Builder::new(); - builder.threaded_scheduler(); + let mut builder = runtime::Builder::new_multi_thread(); builder.enable_all(); builder }) @@ -122,7 +121,8 @@ pub fn block_on(fut: F) -> F::Output { // not a worker thread, not associated with a runtime, make sure we have a runtime (spawn // it on demand if necessary), then enter it let _guard = BlockingGuard::set(); - get_runtime().enter(move || block_on_local_future(fut)) + let _enter_guard = get_runtime().enter(); + get_runtime().block_on(fut) } }