summaryrefslogtreecommitdiffstats
path: root/vendor/crossbeam-epoch/src/default.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/crossbeam-epoch/src/default.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/vendor/crossbeam-epoch/src/default.rs b/vendor/crossbeam-epoch/src/default.rs
index c2b4852a4..b42c1c7a7 100644
--- a/vendor/crossbeam-epoch/src/default.rs
+++ b/vendor/crossbeam-epoch/src/default.rs
@@ -8,22 +8,30 @@ use crate::collector::{Collector, LocalHandle};
use crate::guard::Guard;
use crate::primitive::thread_local;
#[cfg(not(crossbeam_loom))]
-use once_cell::sync::Lazy;
+use crate::sync::once_lock::OnceLock;
-/// The global data for the default garbage collector.
-#[cfg(not(crossbeam_loom))]
-static COLLECTOR: Lazy<Collector> = Lazy::new(Collector::new);
-// FIXME: loom does not currently provide the equivalent of Lazy:
-// https://github.com/tokio-rs/loom/issues/263
-#[cfg(crossbeam_loom)]
-loom::lazy_static! {
- /// The global data for the default garbage collector.
- static ref COLLECTOR: Collector = Collector::new();
+fn collector() -> &'static Collector {
+ #[cfg(not(crossbeam_loom))]
+ {
+ /// The global data for the default garbage collector.
+ static COLLECTOR: OnceLock<Collector> = OnceLock::new();
+ COLLECTOR.get_or_init(Collector::new)
+ }
+ // FIXME: loom does not currently provide the equivalent of Lazy:
+ // https://github.com/tokio-rs/loom/issues/263
+ #[cfg(crossbeam_loom)]
+ {
+ loom::lazy_static! {
+ /// The global data for the default garbage collector.
+ static ref COLLECTOR: Collector = Collector::new();
+ }
+ &COLLECTOR
+ }
}
thread_local! {
/// The per-thread participant for the default garbage collector.
- static HANDLE: LocalHandle = COLLECTOR.register();
+ static HANDLE: LocalHandle = collector().register();
}
/// Pins the current thread.
@@ -40,7 +48,7 @@ pub fn is_pinned() -> bool {
/// Returns the default global collector.
pub fn default_collector() -> &'static Collector {
- &COLLECTOR
+ collector()
}
#[inline]
@@ -50,7 +58,7 @@ where
{
HANDLE
.try_with(|h| f(h))
- .unwrap_or_else(|_| f(&COLLECTOR.register()))
+ .unwrap_or_else(|_| f(&collector().register()))
}
#[cfg(all(test, not(crossbeam_loom)))]