Timer

Struct Timer 

Source
pub struct Timer<T, const N0: usize, const N: usize, const L: usize> { /* private fields */ }
Expand description

不可撤销的定时器

Implementations§

Source§

impl<T, const N0: usize, const N: usize, const L: usize> Timer<T, N0, N, L>

Source

pub fn add_count(&self) -> usize

获得添加任务数量

Source

pub fn remove_count(&self) -> usize

获得移除任务数量

Source

pub fn roll_count(&self) -> u64

获得滚动次数

Source

pub fn push_time(&mut self, time: u64, el: T)

在当前时间之后,放入一个定时任务

Source

pub fn push(&mut self, timeout: usize, el: T)

放入一个定时任务

Source

pub fn pop(&mut self, now: u64) -> Option<T>

弹出一个定时任务

  • now 当前时间
  • @return Option<T> 弹出的定时元素
Source

pub fn is_ok(&mut self, now: u64) -> bool

判断指定时间内是否还有定时任务

Source

pub fn roll(&mut self)

轮滚动 - 向后滚动一个最小粒度, 可能会造成轮的逐层滚动。如果滚动到底,则修正堆上全部的定时任务,并将堆上的到期任务放入轮中

Trait Implementations§

Source§

impl<T: Debug, const N0: usize, const N: usize, const L: usize> Debug for Timer<T, N0, N, L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const N0: usize, const N: usize, const L: usize> Default for Timer<T, N0, N, L>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, const N0: usize, const N: usize, const L: usize> Freeze for Timer<T, N0, N, L>

§

impl<T, const N0: usize, const N: usize, const L: usize> RefUnwindSafe for Timer<T, N0, N, L>
where T: RefUnwindSafe,

§

impl<T, const N0: usize, const N: usize, const L: usize> Send for Timer<T, N0, N, L>
where T: Send,

§

impl<T, const N0: usize, const N: usize, const L: usize> Sync for Timer<T, N0, N, L>
where T: Sync,

§

impl<T, const N0: usize, const N: usize, const L: usize> Unpin for Timer<T, N0, N, L>
where T: Unpin,

§

impl<T, const N0: usize, const N: usize, const L: usize> UnwindSafe for Timer<T, N0, N, L>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.