[−][src]Struct throttle_timer::ThrottleTimer
Methods
impl ThrottleTimer
[src]
Example
use std::time::Duration; use throttle_timer::ThrottleTimer; let mut break_timer: ThrottleTimer = ThrottleTimer::new(Duration::from_secs(1_u64), &"Break"); let do_break_flag = break_timer.do_run(); // Timers always run when no previous runs assert!(do_break_flag == true); if do_break_flag { println!("timer do run flag is set to true") } // Run flag false as no time has passed assert!(break_timer.do_run() == false);
pub fn new(max_frequency: Duration, event_name: &'static str) -> Self
[src]
pub const fn total_calls(&self) -> &usize
[src]
pub const fn max_frequency(&self) -> &Duration
[src]
pub const fn created_date(&self) -> SystemTime
[src]
pub fn print_stats(&self)
[src]
Prints total calls and calls/sec
pub fn do_run(&mut self) -> bool
[src]
Calling do_run()
will check the last call time. If max frequency time has not passed the fn will return false.
If max_frequency duration has passed since the last call then the fn will return true
pub fn do_run_with_msg(&mut self) -> bool
[src]
Same as do_run but will print a message if throttled
Auto Trait Implementations
impl Send for ThrottleTimer
impl Sync for ThrottleTimer
impl Unpin for ThrottleTimer
impl UnwindSafe for ThrottleTimer
impl RefUnwindSafe for ThrottleTimer
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,