Skip to main content

TimedTaskDispatch

Trait TimedTaskDispatch 

Source
pub trait TimedTaskDispatch: TaskDispatch + RuntimeTime {
    // Required methods
    fn spawn_timing_with_config<F, M>(
        &self,
        future: F,
        delay: Duration,
        config: TaskConfig<M>,
    ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output, M>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>, M>>
       where F: Future + Send + 'static,
             F::Output: Send + 'static,
             M: Send + Sync + 'static;
    fn spawn_timing_local_with_config<F, M>(
        future: F,
        delay: Duration,
        config: TaskConfig<M>,
    ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output, M, LocalOutput>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>, M, LocalOutput>>
       where F: Future + 'static,
             F::Output: 'static,
             M: Send + Sync + 'static;

    // Provided methods
    fn spawn_timing<F>(
        &self,
        future: F,
        delay: Duration,
    ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>>>
       where F: Future + Send + 'static,
             F::Output: Send + 'static { ... }
    fn spawn_timing_local<F>(
        future: F,
        delay: Duration,
    ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output, (), LocalOutput>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>, (), LocalOutput>>
       where F: Future + 'static,
             F::Output: 'static { ... }
}
Expand description

同步提交原业务任务(Task)到定时来源;不直接poll,不经普通来源绕行。

Required Methods§

Source

fn spawn_timing_with_config<F, M>( &self, future: F, delay: Duration, config: TaskConfig<M>, ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output, M>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>, M>>
where F: Future + Send + 'static, F::Output: Send + 'static, M: Send + Sync + 'static,

同步固定本次截止时间并提交定时来源;准备失败保原Future,明确拒绝保原任务(Task)和结果句柄(handle)。

Source

fn spawn_timing_local_with_config<F, M>( future: F, delay: Duration, config: TaskConfig<M>, ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output, M, LocalOutput>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>, M, LocalOutput>>
where F: Future + 'static, F::Output: 'static, M: Send + Sync + 'static,

当前原线程内同步定时派发(timed dispatch);原Future/输出不要求Send/Sync,准备和拒绝均保留原值。

Provided Methods§

Source

fn spawn_timing<F>( &self, future: F, delay: Duration, ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>>>
where F: Future + Send + 'static, F::Output: Send + 'static,

默认配置的同步定时派发(timed dispatch);零时长仍入定时来源,不直接执行。

Source

fn spawn_timing_local<F>( future: F, delay: Duration, ) -> RawResult<TaskHandle<TimedTaskNotifier<Self::Notifier, Self::Timer>, F::Output, (), LocalOutput>, SpawnError<F, TimedTaskNotifier<Self::Notifier, Self::Timer>, (), LocalOutput>>
where F: Future + 'static, F::Output: 'static,

默认配置的本地定时派发(timed dispatch);不跳过原所属域或定时来源。

Examples found in repository?
examples/api_bounds.rs (line 19)
12fn local_non_send<R: Runtime>() {
13    let value = Rc::new(Cell::new(1));
14    let _result = R::spawn_local(async move {
15        value.set(2);
16        value
17    });
18    let value = Rc::new(Cell::new(3));
19    let _timed = R::spawn_timing_local(async move { value }, Duration::from_millis(2));
20}

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§