diff options
author | Artem Vorotnikov <artem@vorotnikov.me> | 2020-01-02 22:22:15 +0300 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2020-01-02 11:22:15 -0800 |
commit | e43f28f6a8290d8b452c707de06e2d95236f59e3 (patch) | |
tree | 70ddb8eb9d7cfe7fe2946b9ca8fac3624535025c /tokio-macros | |
parent | 3cf91db4b6429c88a74428ac29b99d3b822f0790 (diff) |
macros: do not automatically pull rt-core (#2038)
Diffstat (limited to 'tokio-macros')
-rw-r--r-- | tokio-macros/src/lib.rs | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index fcdba2bf..bbcc3608 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -20,6 +20,7 @@ use proc_macro::TokenStream; use quote::quote; use std::num::NonZeroUsize; +#[derive(Clone, Copy, PartialEq)] enum Runtime { Basic, Threaded, @@ -145,21 +146,10 @@ fn parse_knobs( } } - let mut rt = quote! { tokio::runtime::Builder::new() }; - match (runtime, is_test) { - (Some(Runtime::Threaded), _) => { - if rt_threaded { - rt = quote! { #rt.threaded_scheduler() } - } - } - (Some(Runtime::Basic), _) => rt = quote! { #rt.basic_scheduler() }, - (None, true) => rt = quote! { #rt.basic_scheduler() }, - (None, false) => { - if rt_threaded { - rt = quote! { #rt.threaded_scheduler() } - } - } - }; + let mut rt = quote! { tokio::runtime::Builder::new().basic_scheduler() }; + if rt_threaded && (runtime == Some(Runtime::Threaded) || (runtime.is_none() && !is_test)) { + rt = quote! { #rt.threaded_scheduler() }; + } if let Some(v) = core_threads.map(|v| v.get()) { rt = quote! { #rt.core_threads(#v) }; } |