fix(server)!: remove time_warn! from the public API (#773)

This is intended to be an internal macro.
This commit is contained in:
Benoît Cortier 2025-04-22 13:33:12 +02:00 committed by GitHub
parent 16651e74a4
commit cc78b1e3dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 25 deletions

View file

@ -12,7 +12,8 @@ use ironrdp_pdu::surface_commands::{ExtendedBitmapDataPdu, SurfaceBitsPdu, Surfa
use self::bitmap::BitmapEncoder;
use self::rfx::RfxEncoder;
use super::BitmapUpdate;
use crate::{time_warn, ColorPointer, DisplayUpdate, Framebuffer, RGBAPointer};
use crate::macros::time_warn;
use crate::{ColorPointer, DisplayUpdate, Framebuffer, RGBAPointer};
mod bitmap;
mod fast_path;

View file

@ -7,6 +7,9 @@ pub use {tokio, tokio_rustls};
#[macro_use]
extern crate tracing;
#[macro_use]
mod macros;
mod builder;
mod capabilities;
mod clipboard;
@ -34,27 +37,3 @@ pub mod bench {
}
}
}
#[macro_export]
macro_rules! time_warn {
($context:expr, $threshold_ms:expr, $op:expr) => {{
#[cold]
fn warn_log(context: &str, duration: u128) {
use ::core::sync::atomic::AtomicUsize;
static COUNT: AtomicUsize = AtomicUsize::new(0);
let current_count = COUNT.fetch_add(1, ::core::sync::atomic::Ordering::Relaxed);
if current_count < 50 || current_count % 100 == 0 {
::tracing::warn!("{context} took {duration} ms! (count: {current_count})");
}
}
let start = std::time::Instant::now();
let result = $op;
let duration = start.elapsed().as_millis();
if duration > $threshold_ms {
warn_log($context, duration);
}
result
}};
}

View file

@ -0,0 +1,24 @@
macro_rules! time_warn {
($context:expr, $threshold_ms:expr, $op:expr) => {{
#[cold]
fn warn_log(context: &str, duration: u128) {
use ::core::sync::atomic::AtomicUsize;
static COUNT: AtomicUsize = AtomicUsize::new(0);
let current_count = COUNT.fetch_add(1, ::core::sync::atomic::Ordering::Relaxed);
if current_count < 50 || current_count % 100 == 0 {
::tracing::warn!("{context} took {duration} ms! (count: {current_count})");
}
}
let start = std::time::Instant::now();
let result = $op;
let duration = start.elapsed().as_millis();
if duration > $threshold_ms {
warn_log($context, duration);
}
result
}};
}
pub(crate) use time_warn;