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§
Source§impl<C, L> DefaultTimerDriver<C, L>
impl<C, L> DefaultTimerDriver<C, L>
Sourcepub 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
Sourcepub fn local_handle(&self) -> LocalTimerHandle<C, L>
pub fn local_handle(&self) -> LocalTimerHandle<C, L>
返回仅本线程可用的同源Weak访问;不增加长期原生拥有者。
Trait Implementations§
Source§impl<C, L> Drop for DefaultTimerDriver<C, L>
impl<C, L> Drop for DefaultTimerDriver<C, L>
Source§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
Source§fn process_cancel_retries(&mut self) -> Result<QueueCleanupProgress>
fn process_cancel_retries(&mut self) -> Result<QueueCleanupProgress>
Source§impl<C, L> TimerTaskQueue for DefaultTimerDriver<C, L>
impl<C, L> TimerTaskQueue for DefaultTimerDriver<C, L>
Source§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)或隐式接纳;已接收后的退场不倒退为提交拒绝。
Source§fn advance(
&mut self,
now: &Self::Instant,
) -> RawResult<TimerAdvanceProgress, TimerQueueError>
fn advance( &mut self, now: &Self::Instant, ) -> RawResult<TimerAdvanceProgress, TimerQueueError>
以显式同源时刻有限推进,不刷新或替换时间轴;时间倒退返回原InvalidTime。 ReachedTarget只表示追时位置,不证明所有到期项均已发现。
Source§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并保管原值;下次重试重新确定范围,不以部分向量冒充全部。
Source§fn process_cleanup(&mut self) -> Result<QueueCleanupProgress>
fn process_cleanup(&mut self) -> Result<QueueCleanupProgress>
有限处理来源清理及取消接续,不以是否到期或空闲决定是否清理。 移交此前无返回口保留的首份原错误;MoreWork或错误不解除剩余责任,纯查询不取走该错误。
Source§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+1ms,开放空源不晚于now+10ms; 时刻夹取MAX,确认来源退出才None;不替代主动通知及停放前重查。
Source§fn close(&mut self) -> Result<QueueCleanupProgress>
fn close(&mut self) -> Result<QueueCleanupProgress>
永久停收并推进来源与取消接续的退出;重复调用幂等(idempotent),用于整体服务关闭。 Complete须两部分责任均结束且没有待报告错误;活动中的本地操作保有实际退出责任。 不表示业务原异步计算(Future)已全部成功析构,不支持关闭计时后继续正常服务的稳态。
Source§type Item = TimerEntry<CancelTimerKey, DefaultTimerRegistration<C, L>>
type Item = TimerEntry<CancelTimerKey, DefaultTimerRegistration<C, L>>
Source§type Instant = GlobalManualInstant
type Instant = GlobalManualInstant
Source§type Key = CancelTimerKey
type Key = CancelTimerKey
Source§type DueBatch = Vec<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item>
type DueBatch = Vec<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item>
Source§type Handle = CancelTimerQueueHandle<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item, ThreadNotifier>
type Handle = CancelTimerQueueHandle<<DefaultTimerDriver<C, L> as TimerTaskQueue>::Item, ThreadNotifier>
Source§fn handle(&self) -> Self::Handle
fn handle(&self) -> Self::Handle
Source§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 moreSource§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取得原值及后续责任;不保证本次已经发现全部到期内容。