From 985bd3f4a105870749fb17ee708dec77c5bf3a3a Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Mon, 14 Feb 2022 10:15:57 -0800 Subject: [PATCH 1/3] rt: make `JoinSet` unstable There are still some open questions related to the API. Until they are resolved, the type should be marked as unstable so releases are not blocked. --- tokio/src/macros/cfg.rs | 10 ++++++++++ tokio/src/runtime/task/mod.rs | 4 ++++ tokio/src/task/mod.rs | 6 ++++-- tokio/src/util/mod.rs | 6 ++++-- tokio/tests/task_join_set.rs | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index 3836aa78b9d..b6beb3d6952 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -373,6 +373,16 @@ macro_rules! cfg_trace { }; } +macro_rules! cfg_unstable { + ($($item:item)*) => { + $( + #[cfg(tokio_unstable)] + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] + $item + )* + }; +} + macro_rules! cfg_not_trace { ($($item:item)*) => { $( diff --git a/tokio/src/runtime/task/mod.rs b/tokio/src/runtime/task/mod.rs index 15e36a0d897..2a492dc985d 100644 --- a/tokio/src/runtime/task/mod.rs +++ b/tokio/src/runtime/task/mod.rs @@ -135,6 +135,10 @@ //! poll call will notice it when the poll finishes, and the task is cancelled //! at that point. +// Some task infrastructure is here to support `JoinSet`, which is currently +// unstable. This should be removed once `JoinSet` is stabilized. +#![cfg_attr(not(tokio_unstable), allow(dead_code))] + mod core; use self::core::Cell; use self::core::Header; diff --git a/tokio/src/task/mod.rs b/tokio/src/task/mod.rs index 7d254190148..d532155a1fe 100644 --- a/tokio/src/task/mod.rs +++ b/tokio/src/task/mod.rs @@ -300,8 +300,10 @@ cfg_rt! { mod unconstrained; pub use unconstrained::{unconstrained, Unconstrained}; - mod join_set; - pub use join_set::JoinSet; + cfg_unstable! { + mod join_set; + pub use join_set::JoinSet; + } cfg_trace! { mod builder; diff --git a/tokio/src/util/mod.rs b/tokio/src/util/mod.rs index 41a3bce051f..618f5543802 100644 --- a/tokio/src/util/mod.rs +++ b/tokio/src/util/mod.rs @@ -44,8 +44,10 @@ pub(crate) mod linked_list; mod rand; cfg_rt! { - mod idle_notified_set; - pub(crate) use idle_notified_set::IdleNotifiedSet; + cfg_unstable! { + mod idle_notified_set; + pub(crate) use idle_notified_set::IdleNotifiedSet; + } mod wake; pub(crate) use wake::WakerRef; diff --git a/tokio/tests/task_join_set.rs b/tokio/tests/task_join_set.rs index 574f216620e..66a2fbb021d 100644 --- a/tokio/tests/task_join_set.rs +++ b/tokio/tests/task_join_set.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(feature = "full")] +#![cfg(all(feature = "full", tokio_unstable))] use tokio::sync::oneshot; use tokio::task::JoinSet; From a45f822e866769a860c3bfdc64a7647f53a415df Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Mon, 14 Feb 2022 10:34:23 -0800 Subject: [PATCH 2/3] fix CI --- tokio/tests/async_send_sync.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index c7e15c4775e..4dfd895afa2 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -434,13 +434,6 @@ async_assert_fn!(tokio::sync::watch::Receiver::changed(_): Send & Sync & !Un async_assert_fn!(tokio::sync::watch::Sender::closed(_): !Send & !Sync & !Unpin); async_assert_fn!(tokio::sync::watch::Sender::closed(_): !Send & !Sync & !Unpin); async_assert_fn!(tokio::sync::watch::Sender::closed(_): Send & Sync & !Unpin); - -async_assert_fn!(tokio::task::JoinSet>::join_one(_): Send & Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet>::join_one(_): !Send & !Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet>::shutdown(_): !Send & !Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet::join_one(_): Send & Sync & !Unpin); -async_assert_fn!(tokio::task::JoinSet::shutdown(_): Send & Sync & !Unpin); async_assert_fn!(tokio::task::LocalKey>::scope(_, Cell, BoxFuture<()>): !Send & !Sync & !Unpin); async_assert_fn!(tokio::task::LocalKey>::scope(_, Cell, BoxFutureSend<()>): Send & !Sync & !Unpin); async_assert_fn!(tokio::task::LocalKey>::scope(_, Cell, BoxFutureSync<()>): Send & !Sync & !Unpin); @@ -458,10 +451,19 @@ assert_value!(tokio::task::JoinError: Send & Sync & Unpin); assert_value!(tokio::task::JoinHandle: !Send & !Sync & Unpin); assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); -assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); -assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); -assert_value!(tokio::task::JoinSet: !Send & !Sync & Unpin); -assert_value!(tokio::task::LocalSet: !Send & !Sync & Unpin); +#[cfg(tokio_unstable)] +mod unstable { + async_assert_fn!(tokio::task::JoinSet>::join_one(_): Send & Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet>::join_one(_): !Send & !Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet>::shutdown(_): !Send & !Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet::join_one(_): Send & Sync & !Unpin); + async_assert_fn!(tokio::task::JoinSet::shutdown(_): Send & Sync & !Unpin); + assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); + assert_value!(tokio::task::JoinSet: Send & Sync & Unpin); + assert_value!(tokio::task::JoinSet: !Send & !Sync & Unpin); + assert_value!(tokio::task::LocalSet: !Send & !Sync & Unpin); +} assert_value!(tokio::runtime::Builder: Send & Sync & Unpin); assert_value!(tokio::runtime::EnterGuard<'_>: Send & Sync & Unpin); From 1f8c31eb3e9dbd2a72317024e083e725d3c35d67 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Mon, 14 Feb 2022 10:43:52 -0800 Subject: [PATCH 3/3] try ci again --- tokio/tests/async_send_sync.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index 4dfd895afa2..ea4445a27f1 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -453,6 +453,7 @@ assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); assert_value!(tokio::task::JoinHandle: Send & Sync & Unpin); #[cfg(tokio_unstable)] mod unstable { + use super::*; async_assert_fn!(tokio::task::JoinSet>::join_one(_): Send & Sync & !Unpin); async_assert_fn!(tokio::task::JoinSet>::shutdown(_): Send & Sync & !Unpin); async_assert_fn!(tokio::task::JoinSet>::join_one(_): !Send & !Sync & !Unpin);