Skip to main content

TimerAccess

Trait TimerAccess 

pub trait TimerAccess:
    Clone
    + Send
    + Sync
    + 'static {
    type Instant: Send + 'static;
    type Key: Send + Sync + 'static;
    type Registration: Clone + Send + Sync + 'static + AsRef<TimerRegistration<Self::Key>>;

    // Required methods
    fn runtime_id(&self) -> RuntimeId;
    fn deadline_after(
        &self,
        duration: Duration,
    ) -> Result<Self::Instant, TimerError>;
    fn prepare_registration(
        &self,
        kind: TimerRegistrationKind,
    ) -> Result<Self::Registration, TimerError>;
    fn try_register(
        &self,
        deadline: Self::Instant,
        item: TimerEntry<Self::Key, Self::Registration>,
    ) -> Result<Self::Key, TimerSubmitError<TimerEntry<Self::Key, Self::Registration>>>;
    fn try_register_local(
        &self,
        deadline: Self::Instant,
        item: TimerEntry<Self::Key, Self::Registration>,
    ) -> Result<Self::Key, TimerSubmitError<TimerEntry<Self::Key, Self::Registration>>>;
    fn request_cancel(
        &self,
        key: &Self::Key,
    ) -> Result<TimerCancelRequestOutcome, TimerQueueError>;
    fn defer_cancel(
        &self,
        registration: Self::Registration,
        error: Option<TimerQueueError>,
        confirmation: Confirmation<'_, Self::Key>,
    );
}
Expand description

供运行时(runtime)实现者连接计时来源的七项操作,通常静态分发。

每个Registration须始终关联同一原来源与基础记录,准备时配齐有限重试所需存储。 成功接受后通知异常不能伪装成未接收;实现必须保留迟到键或真实关闭接续者。

Required Associated Types§

Source

type Instant: Send + 'static

Source

type Key: Send + Sync + 'static

Source

type Registration: Clone + Send + Sync + 'static + AsRef<TimerRegistration<Self::Key>>

Required Methods§

Source

fn runtime_id(&self) -> RuntimeId

读取同一原逻辑服务的身份;不赋予来源管理或执行权限。

Source

fn deadline_after( &self, duration: Duration, ) -> Result<Self::Instant, TimerError>

真实取当前单调时间一次并检查相加;不以无新鲜度保证的旧样本导致提前到期。

Source

fn prepare_registration( &self, kind: TimerRegistrationKind, ) -> Result<Self::Registration, TimerError>

一次准备共享登记与必要重试存储;失败保原报告(Report),不取时、不入队、不创建Task。

Source

fn try_register( &self, deadline: Self::Instant, item: TimerEntry<Self::Key, Self::Registration>, ) -> Result<Self::Key, TimerSubmitError<TimerEntry<Self::Key, Self::Registration>>>

线程安全(thread-safe)尝试接收原登记;明确拒绝返还同一TimerEntry,接受后异常由真实参与者接续,不伪装拒绝。

Source

fn try_register_local( &self, deadline: Self::Instant, item: TimerEntry<Self::Key, Self::Registration>, ) -> Result<Self::Key, TimerSubmitError<TimerEntry<Self::Key, Self::Registration>>>

仅当前合法所属线程可用;错误必须返还原值,本地载荷不额外要求Send/Sync。

Source

fn request_cancel( &self, key: &Self::Key, ) -> Result<TimerCancelRequestOutcome, TimerQueueError>

以同源键(key)记录或合并取消请求(cancellation request),保持原失败原因。 已确认合法关闭接续时,返回 HandledByClose,由同一来源继续清理。 由本次操作确定分类,后续独立采样不能替代发布或关闭接管的证据。

Source

fn defer_cancel( &self, registration: Self::Registration, error: Option<TimerQueueError>, confirmation: Confirmation<'_, Self::Key>, )

接管同一登记的取消责任及可选原错误(error),同步且不等待。

confirmation 只能对应原 registration。先让准备好的原接续节点(node)实际接管, 再确认待接续,随后才允许原节点被取出。已确认由同一来源合法关闭或完成移除时, 可直接结束转交责任。正常返回须完成上述一种交接。 通过 resume_timer_cancel 从原节点有限接续,不新增任务(Task)或每次重试分配。 实现须在已有恐慌(panic)展开时保有原责任,通知(notification)在交接完成后发生。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<C, L> TimerAccess for DefaultTimerAccess<C, L>

Implementors§