Add support for LazyLock

This commit is contained in:
2025-01-17 22:31:40 +01:00
parent 40f835afd2
commit 25ae542ade
6 changed files with 152 additions and 13 deletions

View File

@@ -138,16 +138,14 @@ pub mod tracing {
/// This method will panic if `f` panics, poisoning this `Once`. In addition, this function
/// panics when the lock acquisition order is determined to be inconsistent.
pub fn call_once(&self, f: impl FnOnce()) {
let _borrow = self.id.get_borrowed();
self.inner.call_once(f);
self.id.with_held(|| self.inner.call_once(f));
}
/// Performs the given initialization routine once and only once.
///
/// This method is identical to [`Once::call_once`] except it ignores poisoning.
pub fn call_once_force(&self, f: impl FnOnce(OnceState)) {
let _borrow = self.id.get_borrowed();
self.inner.call_once_force(f);
self.id.with_held(|| self.inner.call_once_force(f));
}
}
}