Struct DefaultTimerDriver
pub struct DefaultTimerDriver<C, L>{ /* private fields */ }Expand description
默认定时接入的唯一线程内驱动(driver),!Send+!Sync,不克隆管理责任。
原生来源使用pi_cancel_timer 0.7,由已冻结队列实现维护;本对象仅连接核心登记和取消重试。 每次advance只消费显式同源时刻;时钟由执行器统一取得,不由队列刷新。 普通业务运行时(runtime)不导出本对象、原生句柄或LocalTimerHandle。 精度及范围沿CancelTimerQueue:1ms,推进向下取整、截止向上取整,不提前交付; 截止为同一起点后0至18,446,744,073,709,000,000ns,参考时刻可达GlobalManualInstant::MAX。 完整到期批次保持当前范围实际发现顺序,空间和处理成本随批次增大,不承诺固定开销。 释放(drop)请求退场;正在执行的本地同步活动可延迟实际清理,不等待外部共享句柄释放才清理原值。
Implementations§
§impl<C, L> DefaultTimerDriver<C, L>
impl<C, L> DefaultTimerDriver<C, L>
pub fn new(
runtime: RuntimeId,
clock: C,
notifier: ThreadNotifier,
options: CancelTimerOptions,
) -> Result<Self>
pub fn new( runtime: RuntimeId, clock: C, notifier: ThreadNotifier, options: CancelTimerOptions, ) -> Result<Self>
在当前线程创建独立来源,真实取同一clock一次作为初始参考;不初始化pi_clock。 同时准备一份接续stub,默认重试工作额度复用options.work_batch_size。
Examples found in repository?
More examples
pub fn from_queue(
runtime: RuntimeId,
clock: C,
notifier: ThreadNotifier,
queue: CancelTimerQueue<DefaultTimerItem<C, L>, ThreadNotifier>,
) -> Result<Self>
pub fn from_queue( runtime: RuntimeId, clock: C, notifier: ThreadNotifier, queue: CancelTimerQueue<DefaultTimerItem<C, L>, ThreadNotifier>, ) -> Result<Self>
接管当前线程已准备的原定时任务队列(timer task queue)。 实例须开放,并使用原执行器(executor)的时间域(time domain)和线程通知句柄(ThreadNotifier)。 首次公开共享访问前核对配对。失败保留原报告(Report),由实际拥有者(owner)释放已接管资源。
pub fn local_handle(&self) -> LocalTimerHandle<C, L>
pub fn local_handle(&self) -> LocalTimerHandle<C, L>
返回仅本线程可用的同源Weak访问;不增加长期原生拥有者。
Trait Implementations§
§impl<C, L> Drop for DefaultTimerDriver<C, L>
impl<C, L> Drop for DefaultTimerDriver<C, L>
§impl<C, L> ExecutorTimer for DefaultTimerDriver<C, L>
impl<C, L> ExecutorTimer for DefaultTimerDriver<C, L>
type Access = DefaultTimerAccess<C, L>
fn timer_access(&self) -> Self::Access
§fn process_cancel_retries(&mut self) -> Result<QueueCleanupProgress>
fn process_cancel_retries(&mut self) -> Result<QueueCleanupProgress>
§impl<C, L> TimerTaskQueue for DefaultTimerDriver<C, L>
impl<C, L> TimerTaskQueue for DefaultTimerDriver<C, L>
§fn try_push_local(
&mut self,
deadline: Self::Instant,
item: Self::Item,
) -> RawResult<Self::Key, TimerSubmitError<Self::Item>>
fn try_push_local( &mut self, deadline: Self::Instant, item: Self::Item, ) -> RawResult<Self::Key, TimerSubmitError<Self::Item>>
在原所属线程(owner thread)提交同源原值,不附加Send/Sync;拒绝返还同一原值及原因。 成功只确认来源接收,不轮询(poll)或隐式接纳;已接收后的退场不倒退为提交拒绝。
§fn advance(
&mut self,
now: &Self::Instant,
) -> RawResult<TimerAdvanceProgress, TimerQueueError>
fn advance( &mut self, now: &Self::Instant, ) -> RawResult<TimerAdvanceProgress, TimerQueueError>
以显式同源时刻有限推进,不刷新或替换时间轴;时间倒退返回原InvalidTime。 ReachedTarget只表示追时位置,不证明所有到期项均已发现。
§fn try_take_due_all(
&mut self,
) -> RawResult<TimerTake<Self::DueBatch>, TimerQueueError>
fn try_take_due_all( &mut self, ) -> RawResult<TimerTake<Self::DueBatch>, TimerQueueError>
完整交付本次固定范围内全部可业务交付的到期原值,保留来源发现顺序,可能超过普通工作额度。 尚不能确认完整返回WouldBlock并保管原值;下次重试重新确定范围,不以部分向量冒充全部。
§fn process_cleanup(&mut self) -> Result<QueueCleanupProgress>
fn process_cleanup(&mut self) -> Result<QueueCleanupProgress>
有限处理来源清理及取消接续,不以是否到期或空闲决定是否清理。 移交此前无返回口保留的首份原错误;MoreWork或错误不解除剩余责任,纯查询不取走该错误。
§fn next_check_at(
&self,
now: &Self::Instant,
) -> RawResult<Option<Self::Instant>, TimerQueueError>
fn next_check_at( &self, now: &Self::Instant, ) -> RawResult<Option<Self::Instant>, TimerQueueError>
只读返回最迟再次检查时刻。仅读取提供的参考时刻和来源状态,取时、推进和通知由其它入口负责。 原生错误原样返回,原生时刻最早为 now。 存在待结清的取消接续时,使用 now + 1ms(饱和于 MAX)和原生时刻中较早者。 原生无时刻时直接使用该保守时刻。没有观察到待结清项时,沿用原生结果。 原生有登记或管理未完不晚于 now + 1ms,开放空来源不晚于 now + 10ms。 原生来源无后续检查且未观察到待结清项时返回 None,关闭完成以清理结果为准。 继续使用主动通知和休眠前重查。
§fn close(&mut self) -> Result<QueueCleanupProgress>
fn close(&mut self) -> Result<QueueCleanupProgress>
永久停收并推进来源与取消接续的退出;重复调用幂等(idempotent),用于整体服务关闭。 Complete须两部分责任均结束且没有待报告错误;活动中的本地操作保有实际退出责任。 不表示业务原异步计算(Future)已全部成功析构,不支持关闭计时后继续正常服务的稳态。
§type Item = TimerEntry<CancelTimerKey, DefaultTimerRegistration<C, L>>
type Item = TimerEntry<CancelTimerKey, DefaultTimerRegistration<C, L>>
§type Instant = GlobalManualInstant
type Instant = GlobalManualInstant
§type Key = CancelTimerKey
type Key = CancelTimerKey
§type DueBatch = Vec<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item>
type DueBatch = Vec<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item>
§type Handle = CancelTimerQueueHandle<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item, ThreadNotifier>
type Handle = CancelTimerQueueHandle<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item, ThreadNotifier>
§fn handle(&self) -> Self::Handle
fn handle(&self) -> Self::Handle
§fn request_cancel_local(
&mut self,
key: &Self::Key,
) -> RawResult<(), TimerCancelRequestError>
fn request_cancel_local( &mut self, key: &Self::Key, ) -> RawResult<(), TimerCancelRequestError>
key的取消请求(cancellation request),不消费键(key)。 Read more§fn try_take_due_one(
&mut self,
) -> RawResult<TimerTake<Self::Item>, TimerQueueError>
fn try_take_due_one( &mut self, ) -> RawResult<TimerTake<Self::Item>, TimerQueueError>
Ready取得原值及后续责任;不保证本次已经发现全部到期内容。