sync: document cancel safety on SetOnce::wait (#7506)

This commit is contained in:
Alice Ryhl
2025-08-03 07:42:30 +00:00
committed by GitHub
parent 4e3f17bce3
commit 9741c90f9f
+3 -6
View File
@@ -338,17 +338,14 @@ impl<T> SetOnce<T> {
}
}
/// Waits until set is called. The future returned will keep blocking until
/// the `SetOnce` is initialized.
/// Waits until the value is set.
///
/// If the `SetOnce` is already initialized, it will return the value
/// immediately.
///
/// # Note
/// # Cancel safety
///
/// This will keep waiting until the `SetOnce` is initialized, so it
/// should be used with care to avoid blocking the current task
/// indefinitely.
/// This method is cancel safe.
pub async fn wait(&self) -> &T {
loop {
if let Some(val) = self.get() {