summaryrefslogtreecommitdiffstats
path: root/tokio/src/io
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/io
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/io')
-rw-r--r--tokio/src/io/driver/mod.rs40
-rw-r--r--tokio/src/io/mod.rs4
-rw-r--r--tokio/src/io/stdio_common.rs6
3 files changed, 34 insertions, 16 deletions
diff --git a/tokio/src/io/driver/mod.rs b/tokio/src/io/driver/mod.rs
index c4f5887a..0d4133a5 100644
--- a/tokio/src/io/driver/mod.rs
+++ b/tokio/src/io/driver/mod.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(not(feature = "rt-core"), allow(dead_code))]
+
mod ready;
use ready::Ready;
@@ -5,7 +7,6 @@ mod scheduled_io;
pub(crate) use scheduled_io::ScheduledIo; // pub(crate) for tests
use crate::park::{Park, Unpark};
-use crate::runtime::context;
use crate::util::bit;
use crate::util::slab::{self, Slab};
@@ -218,17 +219,36 @@ impl fmt::Debug for Driver {
// ===== impl Handle =====
-impl Handle {
- /// Returns a handle to the current reactor
- ///
- /// # Panics
- ///
- /// This function panics if there is no current reactor set.
- pub(super) fn current() -> Self {
- context::io_handle()
- .expect("there is no reactor running, must be called from the context of Tokio runtime")
+cfg_rt_core! {
+ impl Handle {
+ /// Returns a handle to the current reactor
+ ///
+ /// # Panics
+ ///
+ /// This function panics if there is no current reactor set and `rt-core` feature
+ /// flag is not enabled.
+ pub(super) fn current() -> Self {
+ crate::runtime::context::io_handle()
+ .expect("there is no reactor running, must be called from the context of Tokio runtime")
+ }
}
+}
+cfg_not_rt_core! {
+ impl Handle {
+ /// Returns a handle to the current reactor
+ ///
+ /// # Panics
+ ///
+ /// This function panics if there is no current reactor set, or if the `rt-core`
+ /// feature flag is not enabled.
+ pub(super) fn current() -> Self {
+ panic!("there is no reactor running, must be called from the context of Tokio runtime with `rt-core` enabled.")
+ }
+ }
+}
+
+impl Handle {
/// Forces a reactor blocked in a call to `turn` to wakeup, or otherwise
/// makes the next call to `turn` return immediately.
///
diff --git a/tokio/src/io/mod.rs b/tokio/src/io/mod.rs
index e1a036fb..62728ac1 100644
--- a/tokio/src/io/mod.rs
+++ b/tokio/src/io/mod.rs
@@ -250,7 +250,7 @@ cfg_io_blocking! {
/// Types in this module can be mocked out in tests.
mod sys {
// TODO: don't rename
- pub(crate) use crate::runtime::spawn_blocking as run;
- pub(crate) use crate::task::JoinHandle as Blocking;
+ pub(crate) use crate::blocking::spawn_blocking as run;
+ pub(crate) use crate::blocking::JoinHandle as Blocking;
}
}
diff --git a/tokio/src/io/stdio_common.rs b/tokio/src/io/stdio_common.rs
index 03800fcb..d21c842f 100644
--- a/tokio/src/io/stdio_common.rs
+++ b/tokio/src/io/stdio_common.rs
@@ -183,8 +183,7 @@ mod tests {
let fut = async move {
wr.write_all(data.as_bytes()).await.unwrap();
};
- crate::runtime::Builder::new()
- .basic_scheduler()
+ crate::runtime::Builder::new_current_thread()
.build()
.unwrap()
.block_on(fut);
@@ -200,8 +199,7 @@ mod tests {
data.extend(std::iter::repeat(0b1010_1010).take(MAX_BUF - checked_count + 1));
let mut writer = LoggingMockWriter::new();
let mut splitter = super::SplitByUtf8BoundaryIfWindows::new(&mut writer);
- crate::runtime::Builder::new()
- .basic_scheduler()
+ crate::runtime::Builder::new_current_thread()
.build()
.unwrap()
.block_on(async {