From 8880222036f37c6204c8466f25e828447f16dacb Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Mon, 12 Oct 2020 13:44:54 -0400 Subject: rt: Remove `threaded_scheduler()` and `basic_scheduler()` (#2876) Co-authored-by: Alice Ryhl Co-authored-by: Carl Lerche --- tokio/src/signal/registry.rs | 2 +- tokio/src/signal/unix/driver.rs | 45 ++++++++++++++++++++++++++++++----------- tokio/src/signal/windows.rs | 3 +-- 3 files changed, 35 insertions(+), 15 deletions(-) (limited to 'tokio/src/signal') diff --git a/tokio/src/signal/registry.rs b/tokio/src/signal/registry.rs index 9e55a5e6..5d6f608c 100644 --- a/tokio/src/signal/registry.rs +++ b/tokio/src/signal/registry.rs @@ -306,7 +306,7 @@ mod tests { } fn rt() -> Runtime { - runtime::Builder::new().basic_scheduler().build().unwrap() + runtime::Builder::new_current_thread().build().unwrap() } async fn collect(mut rx: crate::sync::mpsc::Receiver<()>) -> Vec<()> { diff --git a/tokio/src/signal/unix/driver.rs b/tokio/src/signal/unix/driver.rs index d0615312..d4a49783 100644 --- a/tokio/src/signal/unix/driver.rs +++ b/tokio/src/signal/unix/driver.rs @@ -1,9 +1,10 @@ +#![cfg_attr(not(feature = "rt-core"), allow(dead_code))] + //! Signal driver use crate::io::driver::Driver as IoDriver; use crate::io::PollEvented; use crate::park::Park; -use crate::runtime::context; use crate::signal::registry::globals; use mio::net::UnixStream; @@ -165,17 +166,6 @@ impl Park for Driver { // ===== impl Handle ===== impl Handle { - /// Returns a handle to the current driver - /// - /// # Panics - /// - /// This function panics if there is no current signal driver set. - pub(super) fn current() -> Self { - context::signal_handle().expect( - "there is no signal driver running, must be called from the context of Tokio runtime", - ) - } - pub(super) fn check_inner(&self) -> io::Result<()> { if self.inner.strong_count() > 0 { Ok(()) @@ -184,3 +174,34 @@ impl Handle { } } } + +cfg_rt_core! { + impl Handle { + /// Returns a handle to the current driver + /// + /// # Panics + /// + /// This function panics if there is no current signal driver set. + pub(super) fn current() -> Self { + crate::runtime::context::signal_handle().expect( + "there is no signal driver running, must be called from the context of Tokio runtime", + ) + } + } +} + +cfg_not_rt_core! { + impl Handle { + /// Returns a handle to the current driver + /// + /// # Panics + /// + /// This function panics if there is no current signal driver set. + pub(super) fn current() -> Self { + panic!( + "there is no signal driver running, must be called from the context of Tokio runtime or with\ + `rt-core` enabled.", + ) + } + } +} diff --git a/tokio/src/signal/windows.rs b/tokio/src/signal/windows.rs index f638eed8..46271722 100644 --- a/tokio/src/signal/windows.rs +++ b/tokio/src/signal/windows.rs @@ -289,8 +289,7 @@ mod tests { } fn rt() -> Runtime { - crate::runtime::Builder::new() - .basic_scheduler() + crate::runtime::Builder::new_current_thread() .build() .unwrap() } -- cgit v1.2.3