summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/notify.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/src/sync/notify.rs')
-rw-r--r--tokio/src/sync/notify.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tokio/src/sync/notify.rs b/tokio/src/sync/notify.rs
index 74c69e50..c69e2b07 100644
--- a/tokio/src/sync/notify.rs
+++ b/tokio/src/sync/notify.rs
@@ -170,6 +170,24 @@ impl Notify {
}
}
+ /// Create a new `Notify`, initialized without a permit.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tokio::sync::Notify;
+ ///
+ /// static NOTIFY: Notify = Notify::const_new();
+ /// ```
+ #[cfg(all(feature = "parking_lot", not(all(loom, test))))]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parking_lot")))]
+ pub const fn const_new() -> Notify {
+ Notify {
+ state: AtomicU8::new(0),
+ waiters: Mutex::const_new(LinkedList::new()),
+ }
+ }
+
/// Wait for a notification.
///
/// Equivalent to: