mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
sync: document cancel safety on SetOnce::wait (#7506)
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user