pub struct TimerWheel { /* private fields */ }Expand description
Hierarchical timing wheel for efficient timer management 用于高效定时器管理的分层时间轮
Uses 4 wheels with different granularities to cover a wide range of timeouts. 使用4个具有不同粒度的轮来覆盖大范围的超时。
Implementations§
Source§impl TimerWheel
impl TimerWheel
Sourcepub fn cancel_timer(&self, id: u64) -> bool
pub fn cancel_timer(&self, id: u64) -> bool
Cancel a timer by ID 通过ID取消定时器
Sourcepub fn current_ticks(&self) -> u64
pub fn current_ticks(&self) -> u64
Get the current tick count 获取当前滴答计数
Sourcepub fn advance(&self, ticks: u64) -> usize
pub fn advance(&self, ticks: u64) -> usize
Advance the timer wheel by the specified number of ticks 将时间轮推进指定数量的滴答
Returns the number of timers that expired during this advancement. 返回在此推进期间到期的定时器数量。
Sourcepub fn insert_timer(&self, duration: Duration) -> TimerHandle
pub fn insert_timer(&self, duration: Duration) -> TimerHandle
Insert a timer with the specified duration 插入具有指定持续时间的定时器
Sourcepub fn insert_timer_with_waker(
&self,
duration: Duration,
waker: Waker,
) -> TimerHandle
pub fn insert_timer_with_waker( &self, duration: Duration, waker: Waker, ) -> TimerHandle
Insert a timer with the specified duration and associated waker 插入具有指定持续时间和关联waker的定时器
Sourcepub fn next_expiration(&self) -> Option<u64>
pub fn next_expiration(&self) -> Option<u64>
Get the next timer expiration time in milliseconds 获取下一个定时器到期时间(毫秒)
Returns None if there are no active timers.
如果没有活动定时器则返回 None。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TimerWheel
impl !RefUnwindSafe for TimerWheel
impl Unpin for TimerWheel
impl UnsafeUnpin for TimerWheel
impl UnwindSafe for TimerWheel
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