Trait ExecutorClock
pub trait ExecutorClock:
Clone
+ Send
+ Sync
+ 'static {
type Instant: Send + 'static;
// Required methods
fn now(&self) -> Result<Self::Instant>;
fn checked_add(
&self,
now: &Self::Instant,
duration: Duration,
) -> Result<Self::Instant>;
fn remaining(
&self,
now: &Self::Instant,
deadline: &Self::Instant,
) -> Result<Duration>;
}Expand description
一份逻辑时间轴;克隆(Clone)不得改变起点或产生另一份独立时间。
正常取时不推进任何任务(Task)或队列。实际系统取时和竞争成本由实现说明; 不以旧缓存冒充新鲜时间,不用时钟值代替业务数据的同步。
Required Associated Types§
Required Methods§
fn checked_add(
&self,
now: &Self::Instant,
duration: Duration,
) -> Result<Self::Instant>
fn checked_add( &self, now: &Self::Instant, duration: Duration, ) -> Result<Self::Instant>
对显式原时刻受检相加;不再次采样,不在越界时回绕或饱和成正常截止。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".