Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros: do not automatically pull rt-core #2038

Merged
merged 2 commits into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions tokio-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use proc_macro::TokenStream;
use quote::quote;
use std::num::NonZeroUsize;

#[derive(Clone, Copy, PartialEq)]
enum Runtime {
Basic,
Threaded,
Expand Down Expand Up @@ -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) };
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ io-driver = ["mio", "lazy_static"]
io-util = ["memchr"]
# stdin, stdout, stderr
io-std = ["rt-core"]
macros = ["rt-core", "tokio-macros"]
macros = ["tokio-macros"]
net = ["dns", "tcp", "udp", "uds"]
process = [
"io-driver",
Expand Down
20 changes: 11 additions & 9 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,18 @@ cfg_time! {
mod util;

cfg_macros! {
cfg_rt_threaded! {
#[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use tokio_macros::main_threaded as main;
pub use tokio_macros::test_threaded as test;
}
doc_rt_core! {
cfg_rt_threaded! {
#[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use tokio_macros::main_threaded as main;
pub use tokio_macros::test_threaded as test;
}

cfg_not_rt_threaded! {
#[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use tokio_macros::main_basic as main;
pub use tokio_macros::test_basic as test;
cfg_not_rt_threaded! {
#[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use tokio_macros::main_basic as main;
pub use tokio_macros::test_basic as test;
}
}
}

Expand Down