Skip to content

Commit cc78b1e

Browse files
authored
fix(server)!: remove time_warn! from the public API (#773)
This is intended to be an internal macro.
1 parent 16651e7 commit cc78b1e

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

crates/ironrdp-server/src/encoder/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use ironrdp_pdu::surface_commands::{ExtendedBitmapDataPdu, SurfaceBitsPdu, Surfa
1212
use self::bitmap::BitmapEncoder;
1313
use self::rfx::RfxEncoder;
1414
use super::BitmapUpdate;
15-
use crate::{time_warn, ColorPointer, DisplayUpdate, Framebuffer, RGBAPointer};
15+
use crate::macros::time_warn;
16+
use crate::{ColorPointer, DisplayUpdate, Framebuffer, RGBAPointer};
1617

1718
mod bitmap;
1819
mod fast_path;

crates/ironrdp-server/src/lib.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ pub use {tokio, tokio_rustls};
77
#[macro_use]
88
extern crate tracing;
99

10+
#[macro_use]
11+
mod macros;
12+
1013
mod builder;
1114
mod capabilities;
1215
mod clipboard;
@@ -34,27 +37,3 @@ pub mod bench {
3437
}
3538
}
3639
}
37-
38-
#[macro_export]
39-
macro_rules! time_warn {
40-
($context:expr, $threshold_ms:expr, $op:expr) => {{
41-
#[cold]
42-
fn warn_log(context: &str, duration: u128) {
43-
use ::core::sync::atomic::AtomicUsize;
44-
45-
static COUNT: AtomicUsize = AtomicUsize::new(0);
46-
let current_count = COUNT.fetch_add(1, ::core::sync::atomic::Ordering::Relaxed);
47-
if current_count < 50 || current_count % 100 == 0 {
48-
::tracing::warn!("{context} took {duration} ms! (count: {current_count})");
49-
}
50-
}
51-
52-
let start = std::time::Instant::now();
53-
let result = $op;
54-
let duration = start.elapsed().as_millis();
55-
if duration > $threshold_ms {
56-
warn_log($context, duration);
57-
}
58-
result
59-
}};
60-
}

crates/ironrdp-server/src/macros.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
macro_rules! time_warn {
2+
($context:expr, $threshold_ms:expr, $op:expr) => {{
3+
#[cold]
4+
fn warn_log(context: &str, duration: u128) {
5+
use ::core::sync::atomic::AtomicUsize;
6+
7+
static COUNT: AtomicUsize = AtomicUsize::new(0);
8+
let current_count = COUNT.fetch_add(1, ::core::sync::atomic::Ordering::Relaxed);
9+
if current_count < 50 || current_count % 100 == 0 {
10+
::tracing::warn!("{context} took {duration} ms! (count: {current_count})");
11+
}
12+
}
13+
14+
let start = std::time::Instant::now();
15+
let result = $op;
16+
let duration = start.elapsed().as_millis();
17+
if duration > $threshold_ms {
18+
warn_log($context, duration);
19+
}
20+
result
21+
}};
22+
}
23+
24+
pub(crate) use time_warn;

0 commit comments

Comments
 (0)