Trait TaskDispatch
pub trait TaskDispatch {
type Notifier: TaskNotifier;
// Required methods
fn create_with_config<F, M>(
&self,
future: F,
config: TaskConfig<M>,
) -> RawResult<(UnsubmittedTask, TaskHandle<Self::Notifier, F::Output, M>), CreateError<F, M>>
where F: Future + Send + 'static,
F::Output: Send + 'static,
M: Send + Sync + 'static;
fn submit(&self, task: UnsubmittedTask) -> RawResult<(), SubmitError>;
// Provided methods
fn create<F>(
&self,
future: F,
) -> RawResult<(UnsubmittedTask, TaskHandle<Self::Notifier, F::Output>), CreateError<F, ()>>
where F: Future + Send + 'static,
F::Output: Send + 'static { ... }
fn spawn_with_config<F, M>(
&self,
future: F,
config: TaskConfig<M>,
) -> RawResult<TaskHandle<Self::Notifier, F::Output, M>, SpawnError<F, Self::Notifier, M>>
where F: Future + Send + 'static,
F::Output: Send + 'static,
M: Send + Sync + 'static { ... }
fn spawn<F>(
&self,
future: F,
) -> RawResult<TaskHandle<Self::Notifier, F::Output>, SpawnError<F, Self::Notifier>>
where F: Future + Send + 'static,
F::Output: Send + 'static { ... }
}Required Associated Types§
type Notifier: TaskNotifier
Required Methods§
fn create_with_config<F, M>(
&self,
future: F,
config: TaskConfig<M>,
) -> RawResult<(UnsubmittedTask, TaskHandle<Self::Notifier, F::Output, M>), CreateError<F, M>>
fn create_with_config<F, M>( &self, future: F, config: TaskConfig<M>, ) -> RawResult<(UnsubmittedTask, TaskHandle<Self::Notifier, F::Output, M>), CreateError<F, M>>
创建原服务的可跨线程任务(Task)并保留配置;不提交、不接纳、不轮询(poll)。失败返还原Future和配置。
fn submit(&self, task: UnsubmittedTask) -> RawResult<(), SubmitError>
fn submit(&self, task: UnsubmittedTask) -> RawResult<(), SubmitError>
向创建它的原服务提交唯一原值;明确拒绝返还原持有及原因,不取消、不改线程归属。
Provided Methods§
fn create<F>(
&self,
future: F,
) -> RawResult<(UnsubmittedTask, TaskHandle<Self::Notifier, F::Output>), CreateError<F, ()>>
fn create<F>( &self, future: F, ) -> RawResult<(UnsubmittedTask, TaskHandle<Self::Notifier, F::Output>), CreateError<F, ()>>
使用默认配置创建;返回唯一待提交值与结果句柄(handle),不隐式派发。
fn spawn_with_config<F, M>(
&self,
future: F,
config: TaskConfig<M>,
) -> RawResult<TaskHandle<Self::Notifier, F::Output, M>, SpawnError<F, Self::Notifier, M>>
fn spawn_with_config<F, M>( &self, future: F, config: TaskConfig<M>, ) -> RawResult<TaskHandle<Self::Notifier, F::Output, M>, SpawnError<F, Self::Notifier, M>>
组合一次创建与提交;错误按创建/提交阶段保留对应原值,成功不表示已经执行。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".