pub struct Timer { /* private fields */ }Expand description
A struct for timing and logging time durations.
Timer uses a HashMap to store multiple named timers, each associated with a label.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn single_instance() -> &'static mut Timer
pub fn single_instance() -> &'static mut Timer
Returns a global singleton instance of Timer
This method implements the singleton pattern to ensure only one Timer instance exists throughout the program. It’s thread-safe and lazily initialized.
§Returns
A static mutable reference to the global Timer instance
§Safety
This function uses an unsafe block because it manipulates static mutable variables. However, thread safety is guaranteed by using Once to ensure initialization happens only once.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more