summaryrefslogtreecommitdiffstats
path: root/tokio-util
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-util
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-util')
-rw-r--r--tokio-util/Cargo.toml1
-rw-r--r--tokio-util/src/cfg.rs10
-rw-r--r--tokio-util/src/codec/bytes_codec.rs2
-rw-r--r--tokio-util/src/context.rs12
-rw-r--r--tokio-util/src/lib.rs4
-rw-r--r--tokio-util/tests/context.rs11
6 files changed, 26 insertions, 14 deletions
diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml
index 8c54f27b..f6007ce2 100644
--- a/tokio-util/Cargo.toml
+++ b/tokio-util/Cargo.toml
@@ -31,6 +31,7 @@ compat = ["futures-io",]
codec = ["tokio/stream"]
time = ["tokio/time","slab"]
io = []
+rt-core = ["tokio/rt-core"]
[dependencies]
tokio = { version = "0.3.0", path = "../tokio" }
diff --git a/tokio-util/src/cfg.rs b/tokio-util/src/cfg.rs
index f9176747..a848223f 100644
--- a/tokio-util/src/cfg.rs
+++ b/tokio-util/src/cfg.rs
@@ -39,3 +39,13 @@ macro_rules! cfg_io {
)*
}
}
+
+macro_rules! cfg_rt_core {
+ ($($item:item)*) => {
+ $(
+ #[cfg(feature = "rt-core")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "rt-core")))]
+ $item
+ )*
+ }
+}
diff --git a/tokio-util/src/codec/bytes_codec.rs b/tokio-util/src/codec/bytes_codec.rs
index a5e73749..275031c0 100644
--- a/tokio-util/src/codec/bytes_codec.rs
+++ b/tokio-util/src/codec/bytes_codec.rs
@@ -33,7 +33,7 @@ use std::io;
/// # }
/// # }
/// #
-/// # #[tokio::main(core_threads = 1)]
+/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() -> Result<(), std::io::Error> {
/// let my_async_read = File::open("filename.txt").await?;
/// let my_stream_of_bytes = FramedRead::new(my_async_read, BytesCodec::new());
diff --git a/tokio-util/src/context.rs b/tokio-util/src/context.rs
index 5f6c6b9b..ae954d85 100644
--- a/tokio-util/src/context.rs
+++ b/tokio-util/src/context.rs
@@ -48,14 +48,14 @@ pub trait RuntimeExt {
/// use tokio_util::context::RuntimeExt;
/// use tokio::time::{sleep, Duration};
///
- /// let rt = tokio::runtime::Builder::new()
- /// .threaded_scheduler()
+ /// let rt = tokio::runtime::Builder::new_multi_thread()
/// .enable_all()
- /// .build().unwrap();
+ /// .build()
+ /// .unwrap();
///
- /// let rt2 = tokio::runtime::Builder::new()
- /// .threaded_scheduler()
- /// .build().unwrap();
+ /// let rt2 = tokio::runtime::Builder::new_multi_thread()
+ /// .build()
+ /// .unwrap();
///
/// let fut = sleep(Duration::from_millis(2));
///
diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs
index 31a16d05..55fd67eb 100644
--- a/tokio-util/src/lib.rs
+++ b/tokio-util/src/lib.rs
@@ -47,7 +47,9 @@ cfg_io! {
pub mod io;
}
-pub mod context;
+cfg_rt_core! {
+ pub mod context;
+}
pub mod sync;
diff --git a/tokio-util/tests/context.rs b/tokio-util/tests/context.rs
index ee519130..852dcd0b 100644
--- a/tokio-util/tests/context.rs
+++ b/tokio-util/tests/context.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "rt-core")]
#![warn(rust_2018_idioms)]
use tokio::runtime::Builder;
@@ -6,15 +7,13 @@ use tokio_util::context::RuntimeExt;
#[test]
fn tokio_context_with_another_runtime() {
- let rt1 = Builder::new()
- .threaded_scheduler()
- .core_threads(1)
+ let rt1 = Builder::new_multi_thread()
+ .worker_threads(1)
// no timer!
.build()
.unwrap();
- let rt2 = Builder::new()
- .threaded_scheduler()
- .core_threads(1)
+ let rt2 = Builder::new_multi_thread()
+ .worker_threads(1)
.enable_all()
.build()
.unwrap();