diff --git a/tokio/src/sync/mutex.rs b/tokio/src/sync/mutex.rs index 1d44e938bf5..be8093163e6 100644 --- a/tokio/src/sync/mutex.rs +++ b/tokio/src/sync/mutex.rs @@ -371,6 +371,11 @@ impl Mutex { /// Creates a new lock in an unlocked state ready for use. /// + /// When using the `tracing` [unstable feature], a `Mutex` created with + /// `const_new` will not be instrumented. As such, it will not be visible + /// in [`tokio-console`]. Instead, [`Mutex::new`] should be used to create + /// an instrumented object if that is needed. + /// /// # Examples /// /// ``` @@ -378,6 +383,9 @@ impl Mutex { /// /// static LOCK: Mutex = Mutex::const_new(5); /// ``` + /// + /// [`tokio-console`]: https://github.com/tokio-rs/console + /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new(t: T) -> Self where diff --git a/tokio/src/sync/notify.rs b/tokio/src/sync/notify.rs index bf00ca3f64f..e1cf5603c2e 100644 --- a/tokio/src/sync/notify.rs +++ b/tokio/src/sync/notify.rs @@ -436,6 +436,11 @@ impl Notify { /// Create a new `Notify`, initialized without a permit. /// + /// When using the `tracing` [unstable feature], a `Notify` created with + /// `const_new` will not be instrumented. As such, it will not be visible + /// in [`tokio-console`]. Instead, [`Notify::new`] should be used to create + /// an instrumented object if that is needed. + /// /// # Examples /// /// ``` @@ -443,6 +448,9 @@ impl Notify { /// /// static NOTIFY: Notify = Notify::const_new(); /// ``` + /// + /// [`tokio-console`]: https://github.com/tokio-rs/console + /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new() -> Notify { Notify { diff --git a/tokio/src/sync/once_cell.rs b/tokio/src/sync/once_cell.rs index 178d29bfecd..1a2303e8e6a 100644 --- a/tokio/src/sync/once_cell.rs +++ b/tokio/src/sync/once_cell.rs @@ -153,6 +153,11 @@ impl OnceCell { /// /// # Example /// + /// When using the `tracing` [unstable feature], a `OnceCell` created with + /// `const_new_with` will not be instrumented. As such, it will not be + /// visible in [`tokio-console`]. Instead, [`OnceCell::new_with`] should be + /// used to create an instrumented object if that is needed. + /// /// ``` /// use tokio::sync::OnceCell; /// @@ -170,6 +175,9 @@ impl OnceCell { /// assert_eq!(*result, 1); /// } /// ``` + /// + /// [`tokio-console`]: https://github.com/tokio-rs/console + /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new_with(value: T) -> Self { OnceCell { @@ -184,6 +192,11 @@ impl OnceCell { /// Equivalent to `OnceCell::new`, except that it can be used in static /// variables. /// + /// When using the `tracing` [unstable feature], a `OnceCell` created with + /// `const_new` will not be instrumented. As such, it will not be visible + /// in [`tokio-console`]. Instead, [`OnceCell::new`] should be used to + /// create an instrumented object if that is needed. + /// /// # Example /// /// ``` @@ -203,6 +216,9 @@ impl OnceCell { /// assert_eq!(*result, 2); /// } /// ``` + /// + /// [`tokio-console`]: https://github.com/tokio-rs/console + /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new() -> Self { OnceCell { diff --git a/tokio/src/sync/rwlock.rs b/tokio/src/sync/rwlock.rs index ba464eab939..37d7f65fe7b 100644 --- a/tokio/src/sync/rwlock.rs +++ b/tokio/src/sync/rwlock.rs @@ -327,6 +327,11 @@ impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// + /// When using the `tracing` [unstable feature], a `RwLock` created with + /// `const_new` will not be instrumented. As such, it will not be visible + /// in [`tokio-console`]. Instead, [`RwLock::new`] should be used to create + /// an instrumented object if that is needed. + /// /// # Examples /// /// ``` @@ -334,6 +339,9 @@ impl RwLock { /// /// static LOCK: RwLock = RwLock::const_new(5); /// ``` + /// + /// [`tokio-console`]: https://github.com/tokio-rs/console + /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new(value: T) -> RwLock where diff --git a/tokio/src/sync/semaphore.rs b/tokio/src/sync/semaphore.rs index 348134a9062..ef18afa32f0 100644 --- a/tokio/src/sync/semaphore.rs +++ b/tokio/src/sync/semaphore.rs @@ -194,6 +194,11 @@ impl Semaphore { /// Creates a new semaphore with the initial number of permits. /// + /// When using the `tracing` [unstable feature], a `Semaphore` created with + /// `const_new` will not be instrumented. As such, it will not be visible + /// in [`tokio-console`]. Instead, [`Semaphore::new`] should be used to + /// create an instrumented object if that is needed. + /// /// # Examples /// /// ``` @@ -201,6 +206,9 @@ impl Semaphore { /// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``` + /// + /// [`tokio-console`]: https://github.com/tokio-rs/console + /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new(permits: usize) -> Self { Self {