Skip to content

Commit 4f436e0

Browse files
committed
tokio: Stabilize LocalRuntime
1 parent 2f30df7 commit 4f436e0

File tree

8 files changed

+15
-24
lines changed

8 files changed

+15
-24
lines changed

tests-integration/tests/macros_main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ async fn spawning() -> usize {
1616
join.await.unwrap()
1717
}
1818

19-
#[cfg(tokio_unstable)]
2019
#[tokio::main(flavor = "local")]
2120
async fn local_main() -> usize {
2221
let join = tokio::task::spawn_local(async { 1 });
@@ -33,6 +32,5 @@ fn shell() {
3332
assert_eq!(1, basic_main());
3433
assert_eq!(bool::default(), generic_fun::<bool>());
3534

36-
#[cfg(tokio_unstable)]
3735
assert_eq!(1, local_main());
3836
}

tokio/src/runtime/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#![cfg_attr(loom, allow(unused_imports))]
22

33
use crate::runtime::handle::Handle;
4-
use crate::runtime::{blocking, driver, Callback, HistogramBuilder, Runtime, TaskCallback};
4+
use crate::runtime::{
5+
blocking, driver, Callback, HistogramBuilder, LocalOptions, LocalRuntime, Runtime, TaskCallback,
6+
};
57
#[cfg(tokio_unstable)]
6-
use crate::runtime::{metrics::HistogramConfiguration, LocalOptions, LocalRuntime, TaskMeta};
8+
use crate::runtime::{metrics::HistogramConfiguration, TaskMeta};
79
use crate::util::rand::{RngSeed, RngSeedGenerator};
810

911
use crate::runtime::blocking::BlockingPool;
@@ -923,7 +925,6 @@ impl Builder {
923925
/// });
924926
/// ```
925927
#[allow(unused_variables, unreachable_patterns)]
926-
#[cfg(tokio_unstable)]
927928
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
928929
pub fn build_local(&mut self, options: LocalOptions) -> io::Result<LocalRuntime> {
929930
match &self.kind {
@@ -1438,7 +1439,6 @@ impl Builder {
14381439
))
14391440
}
14401441

1441-
#[cfg(tokio_unstable)]
14421442
fn build_current_thread_local_runtime(&mut self) -> io::Result<LocalRuntime> {
14431443
use crate::runtime::local_runtime::LocalRuntimeScheduler;
14441444

tokio/src/runtime/handle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,13 @@ impl Handle {
361361
{
362362
let id = crate::runtime::task::Id::next();
363363
#[cfg(all(
364-
tokio_unstable,
365364
tokio_taskdump,
366365
feature = "rt",
367366
target_os = "linux",
368367
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
369368
))]
370369
let future = super::task::trace::Trace::root(future);
371-
#[cfg(all(tokio_unstable, feature = "tracing"))]
370+
#[cfg(feature = "tracing")]
372371
let future = crate::util::trace::task(future, "task", meta, id.as_u64());
373372
self.inner.spawn_local(future, id, meta.spawned_at)
374373
}

tokio/src/runtime/local_runtime/runtime.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::time::Duration;
2929
/// [runtime]: crate::runtime::Runtime
3030
/// [module]: crate::runtime
3131
#[derive(Debug)]
32-
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
3332
pub struct LocalRuntime {
3433
/// Task scheduler
3534
scheduler: LocalRuntimeScheduler,
@@ -231,15 +230,14 @@ impl LocalRuntime {
231230
#[track_caller]
232231
fn block_on_inner<F: Future>(&self, future: F, _meta: SpawnMeta<'_>) -> F::Output {
233232
#[cfg(all(
234-
tokio_unstable,
235233
tokio_taskdump,
236234
feature = "rt",
237235
target_os = "linux",
238236
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
239237
))]
240238
let future = crate::runtime::task::trace::Trace::root(future);
241239

242-
#[cfg(all(tokio_unstable, feature = "tracing"))]
240+
#[cfg(feature = "tracing")]
243241
let future = crate::util::trace::task(
244242
future,
245243
"block_on",
@@ -320,6 +318,7 @@ impl LocalRuntime {
320318
/// use std::time::Duration;
321319
///
322320
/// fn main() {
321+
/// # if cfg!(miri) { return } // Miri reports error when main thread terminated without waiting all remaining threads.
323322
/// let runtime = LocalRuntime::new().unwrap();
324323
///
325324
/// runtime.block_on(async move {

tokio/src/runtime/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@ cfg_rt! {
371371
pub use self::builder::UnhandledPanic;
372372
pub use crate::util::rand::RngSeed;
373373

374-
mod local_runtime;
375-
pub use local_runtime::{LocalRuntime, LocalOptions};
376374
}
377375

378376
cfg_taskdump! {
@@ -394,6 +392,9 @@ cfg_rt! {
394392
mod runtime;
395393
pub use runtime::{Runtime, RuntimeFlavor};
396394

395+
mod local_runtime;
396+
pub use local_runtime::{LocalRuntime, LocalOptions};
397+
397398
/// Boundary value to prevent stack overflow caused by a large-sized
398399
/// Future being placed in the stack.
399400
pub(crate) const BOX_FUTURE_THRESHOLD: usize = if cfg!(debug_assertions) {

tokio/src/task/local.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ cfg_rt! {
327327
/// Spawns a `!Send` future on the current [`LocalSet`] or [`LocalRuntime`].
328328
///
329329
/// This is possible when either using one of these types
330-
/// explicitly, or (with `tokio_unstable`) by opting to use the
330+
/// explicitly by opting to use the
331331
/// `"local"` runtime flavor in `tokio::main`:
332332
///
333333
/// ```ignore
@@ -407,7 +407,6 @@ cfg_rt! {
407407
let future = future.take().unwrap();
408408

409409
#[cfg(all(
410-
tokio_unstable,
411410
tokio_taskdump,
412411
feature = "rt",
413412
target_os = "linux",

tokio/tests/async_send_sync.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ assert_value!(tokio::runtime::EnterGuard<'_>: !Send & Sync & Unpin);
559559
assert_value!(tokio::runtime::Handle: Send & Sync & Unpin);
560560
assert_value!(tokio::runtime::Runtime: Send & Sync & Unpin);
561561

562+
assert_value!(tokio::runtime::LocalRuntime: !Send & !Sync & Unpin);
563+
assert_value!(tokio::runtime::LocalOptions: !Send & !Sync & Unpin);
564+
562565
assert_value!(tokio::time::Interval: Send & Sync & Unpin);
563566
assert_value!(tokio::time::Instant: Send & Sync & Unpin);
564567
assert_value!(tokio::time::Sleep: Send & Sync & !Unpin);
@@ -768,11 +771,3 @@ mod unix_asyncfd {
768771
async_assert_fn!(AsyncFd<ImplsFd<NN>>::writable(_): !Send & !Sync & !Unpin);
769772
async_assert_fn!(AsyncFd<ImplsFd<NN>>::writable_mut(_): !Send & !Sync & !Unpin);
770773
}
771-
772-
#[cfg(tokio_unstable)]
773-
mod unstable {
774-
use super::*;
775-
776-
assert_value!(tokio::runtime::LocalRuntime: !Send & !Sync & Unpin);
777-
assert_value!(tokio::runtime::LocalOptions: !Send & !Sync & Unpin);
778-
}

tokio/tests/rt_local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", tokio_unstable))]
2+
#![cfg(feature = "full")]
33

44
use tokio::runtime::LocalOptions;
55
use tokio::task::spawn_local;

0 commit comments

Comments
 (0)