summaryrefslogtreecommitdiffstats
path: root/tokio/src/signal
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-10-12 13:44:54 -0400
committerGitHub <noreply@github.com>2020-10-12 13:44:54 -0400
commit8880222036f37c6204c8466f25e828447f16dacb (patch)
treefd623afc20f73bbce65746a3d1b1b2731ecf30a5 /tokio/src/signal
parent0893841f31542b2b04c5050a8a4a3c45cf867e55 (diff)
rt: Remove `threaded_scheduler()` and `basic_scheduler()` (#2876)
Co-authored-by: Alice Ryhl <alice@ryhl.io> Co-authored-by: Carl Lerche <me@carllerche.com>
Diffstat (limited to 'tokio/src/signal')
-rw-r--r--tokio/src/signal/registry.rs2
-rw-r--r--tokio/src/signal/unix/driver.rs45
-rw-r--r--tokio/src/signal/windows.rs3
3 files changed, 35 insertions, 15 deletions
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()
}