Skip to main content

TimerHandle

Struct TimerHandle 

Source
pub struct TimerHandle { /* private fields */ }
Expand description

定时任务句柄 —— 支持显式取消与滑动重置;句柄析构不会自动取消。

Implementations§

Source§

impl TimerHandle

Source

pub fn cancel(&self)

取消该定时任务(对已触发的 once 任务为 no-op)。

Source

pub fn is_cancelled(&self) -> bool

是否已取消(反映调用方意图,不反映驱动侧实际状态)。

Source

pub fn has_fired(&self) -> bool

该 once 任务是否已触发。

触发标记在驱动执行到点动作之前置位,且 Actor 事件循环 单线程消费消息,因此“触发后首批消息先于定时消息被处理” 不可能发生 —— 该查询在 Actor 上下文内无竞态。 周期任务恒返回 false(无单次触发语义)。

Source

pub fn reset(&self, delay: Duration)

滑动 deadline:从现在起重新等待 delay。对已触发/已取消的任务为 no-op。

复用既有条目:驱动内活跃条目保持 O(1),不产生已取消条目残留。 代价是每次调用向驱动投递一条重置命令(跨任务发送 + 堆插入 + 唤醒驱动)。

高频滑动(如每帧喂狗,100–1000Hz)请改用 ActorContext::watchdog:其滑动 走共享原子 deadline,零跨任务命令、零驱动唤醒。

Trait Implementations§

Source§

impl Clone for TimerHandle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimerHandle

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> ActorMsg for T
where T: Send + 'static,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more