Skip to content

Commit 8198125

Browse files
committed
fix: Profiler should use OnceLock, not OnceCell
1 parent cefbc5b commit 8198125

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

profiling/src/profiling/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ use libdd_profiling::exporter::Tag;
3131
use libdd_profiling::internal::Profile as InternalProfile;
3232
use log::{debug, info, trace, warn};
3333
use std::borrow::Cow;
34-
use std::cell::OnceCell;
3534
use std::collections::HashMap;
3635
use std::hash::Hash;
3736
use std::num::NonZeroI64;
3837
use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering};
39-
use std::sync::{Arc, Barrier};
38+
use std::sync::{Arc, Barrier, OnceLock};
4039
use std::thread::JoinHandle;
4140
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
4241

@@ -58,7 +57,7 @@ const UPLOAD_CHANNEL_CAPACITY: usize = 8;
5857

5958
/// The global profiler. Profiler gets made during the first rinit after an
6059
/// minit, and is destroyed on mshutdown.
61-
static mut PROFILER: OnceCell<Profiler> = OnceCell::new();
60+
static mut PROFILER: OnceLock<Profiler> = OnceLock::new();
6261

6362
/// Order this array this way:
6463
/// 1. Always enabled types.
@@ -657,7 +656,7 @@ const DDPROF_TIME: &str = "ddprof_time";
657656
const DDPROF_UPLOAD: &str = "ddprof_upload";
658657

659658
impl Profiler {
660-
/// Will initialize the `PROFILER` OnceCell and makes sure that only one thread will do so.
659+
/// Will initialize the `PROFILER` OnceLock and makes sure that only one thread will do so.
661660
pub fn init(system_settings: &SystemSettings) {
662661
// SAFETY: the `get_or_init` access is a thread-safe API, and the
663662
// PROFILER is only being mutated in single-threaded phases such as

0 commit comments

Comments
 (0)