Trait IdleDispatch
pub trait IdleDispatch: TaskDispatch {
// Required methods
fn submit_idle(&self, task: UnsubmittedTask) -> Result<(), SubmitError>;
fn idle_local_with_config<F, M>(
future: F,
config: TaskConfig<M>,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M>, SpawnError<F, Self::Notifier, M>>
where F: Future + Send + 'static,
<F as Future>::Output: Send + 'static,
M: Send + Sync + 'static;
// Provided methods
fn idle_with_config<F, M>(
&self,
future: F,
config: TaskConfig<M>,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M>, SpawnError<F, Self::Notifier, M>>
where F: Future + Send + 'static,
<F as Future>::Output: Send + 'static,
M: Send + Sync + 'static { ... }
fn idle<F>(
&self,
future: F,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output>, SpawnError<F, Self::Notifier>>
where F: Future + Send + 'static,
<F as Future>::Output: Send + 'static { ... }
fn idle_local<F>(
future: F,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output>, SpawnError<F, Self::Notifier>>
where F: Future + Send + 'static,
<F as Future>::Output: Send + 'static { ... }
}Expand description
空闲来源不判断是否空闲;提交成功不承诺一定被接纳或执行。
Required Methods§
Sourcefn submit_idle(&self, task: UnsubmittedTask) -> Result<(), SubmitError>
fn submit_idle(&self, task: UnsubmittedTask) -> Result<(), SubmitError>
向同一服务的空闲来源提交普通Send任务(Task);不检查空闲、不保证未来接纳。
Sourcefn idle_local_with_config<F, M>(
future: F,
config: TaskConfig<M>,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M>, SpawnError<F, Self::Notifier, M>>
fn idle_local_with_config<F, M>( future: F, config: TaskConfig<M>, ) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M>, SpawnError<F, Self::Notifier, M>>
从当前环境定位原服务后提交共享空闲来源;Future与输出要求Send,不要求Sync,不预先绑定执行线程。
Provided Methods§
Sourcefn idle_with_config<F, M>(
&self,
future: F,
config: TaskConfig<M>,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M>, SpawnError<F, Self::Notifier, M>>
fn idle_with_config<F, M>( &self, future: F, config: TaskConfig<M>, ) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M>, SpawnError<F, Self::Notifier, M>>
创建并提交空闲时任务(idle task);成功只证明来源接受,不保证执行。
Sourcefn idle<F>(
&self,
future: F,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output>, SpawnError<F, Self::Notifier>>
fn idle<F>( &self, future: F, ) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output>, SpawnError<F, Self::Notifier>>
默认配置的空闲提交;任务(Task)未接纳前仍可按原控制能力取消。
Sourcefn idle_local<F>(
future: F,
) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output>, SpawnError<F, Self::Notifier>>
fn idle_local<F>( future: F, ) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output>, SpawnError<F, Self::Notifier>>
默认配置的当前空闲提交;输入保持Send约束,不等同spawn_local的本地非Send能力。
Examples found in repository?
examples/runtime_bounds.rs (line 62)
39fn roots(runtime: &ConcurrentRuntime, handle: &Handle) {
40 let value = Rc::new(7);
41 let _: Rc<usize> = runtime.block_on(Borrowed {
42 value: &value,
43 fixed: PhantomPinned,
44 });
45 let _: Rc<usize> = handle.block_on(Borrowed {
46 value: &value,
47 fixed: PhantomPinned,
48 });
49 let _ = runtime.timeout_on(
50 Borrowed {
51 value: &value,
52 fixed: PhantomPinned,
53 },
54 std::time::Duration::from_millis(1),
55 );
56 let _ = handle.spawn(SendNotSync {
57 value: Cell::new(3),
58 fixed: PhantomPinned,
59 });
60 let _ = ConcurrentRuntime::spawn_local(async { Rc::new(1usize) });
61 let _ = ConcurrentRuntime::spawn_local_front(async { Rc::new(2usize) });
62 let _ = SerialRuntime::idle_local(async { Cell::new(4usize) });
63 let _ = handle.wait_one_timeout::<Rc<usize>>(std::time::Duration::from_secs(2));
64}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".