[pbs-devel] [PATCH proxmox-backup 05/12] tokio: adapt to 1.0 runtime changes

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Jan 12 14:58:19 CET 2021


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 <f.gruenbichler at proxmox.com>
---
 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<F: Fn() -> runtime::Builder>(get_builder: F) ->
 pub fn get_runtime() -> Arc<Runtime> {
 
     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<F: Future>(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)
     }
 }
 
-- 
2.20.1






More information about the pbs-devel mailing list