mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-04 15:18:17 +00:00
fix(server)!: remove time_warn! from the public API (#773)
This is intended to be an internal macro.
This commit is contained in:
parent
16651e74a4
commit
cc78b1e3dc
3 changed files with 29 additions and 25 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}};
|
||||
}
|
||||
|
|
24
crates/ironrdp-server/src/macros.rs
Normal file
24
crates/ironrdp-server/src/macros.rs
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue