Skip to content

Commit 9bd20f8

Browse files
committed
i have big dumb
1 parent a8a7579 commit 9bd20f8

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ caith = { version = "4.2.4", optional = true }
6969
uuid = { version = "1.17", optional = true, features = ["v4", "v7", "fast-rng"] }
7070
cuid2 = { version = "0.1.4", optional = true }
7171
dhat = "0.3"
72+
ctor = "0.4"
7273

7374
[features]
7475
default = [

src/dhat.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ static ALLOC: dhat::Alloc = dhat::Alloc;
66

77
static PROFILER: LazyLock<Mutex<Option<Profiler>>> = LazyLock::new(Mutex::default);
88

9-
pub fn start_dhat(path: String) {
9+
byond_fn!(fn start_dhat(path) {
1010
let mut profiler = PROFILER.lock().unwrap();
1111
if let Some(old_profiler) = profiler.take() {
1212
std::mem::drop(old_profiler);
1313
}
1414
*profiler = Some(Profiler::builder().file_name(path).build());
15-
}
15+
Some("")
16+
});
17+
18+
byond_fn!(
19+
fn stop_dhat() {
20+
std::mem::drop(PROFILER.lock().unwrap().take());
21+
Some("")
22+
}
23+
);
1624

17-
pub fn stop_dhat() {
18-
std::mem::drop(PROFILER.lock().unwrap().take());
25+
#[ctor::dtor]
26+
fn ensure_dhat_stopped() {
27+
if let Ok(mut profiler) = PROFILER.try_lock() {
28+
std::mem::drop(profiler.take());
29+
};
1930
}

0 commit comments

Comments
 (0)