Skip to main content

TimerQueueHandle

Trait TimerQueueHandle 

pub trait TimerQueueHandle:
    Clone
    + Send
    + Sync
    + 'static {
    type Item;
    type Instant;
    type Key: Send + Sync + 'static;

    // Required methods
    fn try_push(
        &self,
        deadline: Self::Instant,
        item: Self::Item,
    ) -> RawResult<Self::Key, TimerSubmitError<Self::Item>>
       where Self::Item: Send + 'static,
             Self::Instant: Send + 'static;
    fn request_cancel(
        &self,
        key: &Self::Key,
    ) -> RawResult<(), TimerCancelRequestError>;
    fn status(&self) -> TimerQueueStatus;
    fn len(&self) -> usize;
    fn is_empty(&self) -> bool;
}
Expand description

同一原定时来源的线程安全共享入口;不提供推进、取出或实际管理权限。

克隆(Clone)共享入口不复制来源,不强制Arc布局。共享入口存续不能阻止原 异步计算(Future)的合法析构(drop),也不能重新开放已关闭服务。 调用同步、非等待;允许已说明的短时同步成本,不无限自旋或等待未来任务(Task)。

Required Associated Types§

type Item

与本地拥有者关联的原登记内容;共享提交方法另加Send约束。

type Instant

与原来源相同时间域的绝对时刻,不独立选择另一时钟。

type Key: Send + Sync + 'static

与原来源关联的不透明键(opaque key);正常释放不取消。

Required Methods§

fn try_push( &self, deadline: Self::Instant, item: Self::Item, ) -> RawResult<Self::Key, TimerSubmitError<Self::Item>>
where Self::Item: Send + 'static, Self::Instant: Send + 'static,

尝试接收同源绝对deadline及原item;成功立即返回原登记身份。

即使内容尚在共享中转区,返回键(key)也必须已经有效关联;接收后发布失败不能 伪装未接收。明确拒绝返还原item。仅此方法要求内容和时刻Send + ’static, 不要求Sync;共享入口可跨线程(thread)访问不授权跨线程触及本地原异步计算(Future)。 成功发布后安排所属线程(owner thread)继续检查;必要通知失败不撤销已接收事实。

fn request_cancel( &self, key: &Self::Key, ) -> RawResult<(), TimerCancelRequestError>

借用key记录/合并取消请求(cancellation request),不等待目标清理。

Ok(())不证明目标存在、请求落实或取消成功;只有已知不能发布才返回错误。 请求发布后安排所属线程(owner thread)继续检查,通知失败不撤销已经记录的事实。 共享调用不返回WrongOwner,错来源及过期身份绝不能命中另一登记。

fn status(&self) -> TimerQueueStatus

安全读取原来源状态快照(snapshot);不推进计时或清理,不重开已关闭服务。

fn len(&self) -> usize

按拥有者len同一口径安全取样,不承诺与其它查询处于同一瞬间。

fn is_empty(&self) -> bool

按同一计数口径查询当次是否为零,不承诺下一次取出或整体退出条件。

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§