Struct DefaultTimerAccess
pub struct DefaultTimerAccess<C: ExecutorClock<Instant = GlobalManualInstant>, L: 'static> { /* private fields */ }Expand description
同一计时来源的Clone+Send+Sync访问;不保本地容器或可写线程局部指针。
正常业务通过运行时(runtime)的timeout/sleep等使用。C为同源时钟,L为静态本地接入; 外部签名不要求业务Future的Unpin或额外Sync,最终运行时别名隐藏这两个实现参数。
Trait Implementations§
§impl<C: ExecutorClock<Instant = GlobalManualInstant>, L: 'static> Clone for DefaultTimerAccess<C, L>
impl<C: ExecutorClock<Instant = GlobalManualInstant>, L: 'static> Clone for DefaultTimerAccess<C, L>
§impl<C, L> TimerAccess for DefaultTimerAccess<C, L>
impl<C, L> TimerAccess for DefaultTimerAccess<C, L>
type Instant = GlobalManualInstant
type Key = CancelTimerKey
type Registration = DefaultTimerRegistration<C, L>
§fn runtime_id(&self) -> RuntimeId
fn runtime_id(&self) -> RuntimeId
读取同一原逻辑服务的身份;不赋予来源管理或执行权限。
§fn deadline_after(
&self,
duration: Duration,
) -> RawResult<Self::Instant, TimerError>
fn deadline_after( &self, duration: Duration, ) -> RawResult<Self::Instant, TimerError>
真实取当前单调时间一次并检查相加;不以无新鲜度保证的旧样本导致提前到期。
§fn prepare_registration(
&self,
kind: TimerRegistrationKind,
) -> RawResult<Self::Registration, TimerError>
fn prepare_registration( &self, kind: TimerRegistrationKind, ) -> RawResult<Self::Registration, TimerError>
一次准备共享登记与必要重试存储;失败保原报告(Report),不取时、不入队、不创建Task。
§fn try_register(
&self,
deadline: Self::Instant,
item: DefaultTimerItem<C, L>,
) -> RawResult<Self::Key, TimerSubmitError<DefaultTimerItem<C, L>>>
fn try_register( &self, deadline: Self::Instant, item: DefaultTimerItem<C, L>, ) -> RawResult<Self::Key, TimerSubmitError<DefaultTimerItem<C, L>>>
线程安全(thread-safe)尝试接收原登记;明确拒绝返还同一TimerEntry,接受后异常由真实参与者接续,不伪装拒绝。
§fn try_register_local(
&self,
deadline: Self::Instant,
item: DefaultTimerItem<C, L>,
) -> RawResult<Self::Key, TimerSubmitError<DefaultTimerItem<C, L>>>
fn try_register_local( &self, deadline: Self::Instant, item: DefaultTimerItem<C, L>, ) -> RawResult<Self::Key, TimerSubmitError<DefaultTimerItem<C, L>>>
仅当前合法所属线程可用;错误必须返还原值,本地载荷不额外要求Send/Sync。
§fn request_cancel(
&self,
key: &Self::Key,
) -> RawResult<TimerCancelRequestOutcome, TimerQueueError>
fn request_cancel( &self, key: &Self::Key, ) -> RawResult<TimerCancelRequestOutcome, TimerQueueError>
以同源键(key)记录或合并取消请求(cancellation request),保持原失败原因。
已确认合法关闭接续时,返回
HandledByClose,由同一来源继续清理。
由本次操作确定分类,后续独立采样不能替代发布或关闭接管的证据。§fn defer_cancel(
&self,
registration: Self::Registration,
error: Option<TimerQueueError>,
confirmation: Confirmation<'_, Self::Key>,
)
fn defer_cancel( &self, registration: Self::Registration, error: Option<TimerQueueError>, confirmation: Confirmation<'_, Self::Key>, )
接管同一登记的取消责任及可选原错误(error),同步且不等待。 Read more
Auto Trait Implementations§
impl<C, L> !RefUnwindSafe for DefaultTimerAccess<C, L>
impl<C, L> !UnwindSafe for DefaultTimerAccess<C, L>
impl<C, L> Forget for DefaultTimerAccess<C, L>
impl<C, L> Freeze for DefaultTimerAccess<C, L>
impl<C, L> Move for DefaultTimerAccess<C, L>
impl<C, L> Send for DefaultTimerAccess<C, L>
impl<C, L> Sync for DefaultTimerAccess<C, L>
impl<C, L> Unpin for DefaultTimerAccess<C, L>
impl<C, L> UnsafeUnpin for DefaultTimerAccess<C, L>where
Arc<TimerSourceShared<C, L>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more