Skip to main content

RuntimeHandle

Struct RuntimeHandle 

pub struct RuntimeHandle<C, E = MpscTaskQueueHandle, I = MpscIdleTaskQueueHandle, T = DefaultTimerDriver<C, RuntimeTag<C>>>{ /* private fields */ }
Expand description

定制时钟的共享访问;通常由构造结果推导,默认用户使用不带参数的Handle。 两项等待唤醒/待取消查询与ConfiguredRuntime相同,按需O(n)扫描登记,其它操作沿对应能力约定。 释放(drop)本句柄不关闭服务,不延迟本地原异步计算(Future)的合法清理。

Implementations§

§

impl<C, E, I, T> RuntimeHandle<C, E, I, T>

pub fn submit_local_front(task: UnsubmittedTask) -> RawResult<(), SubmitError>

由当前原线程把首次提交放内部头;无本地权限时返原值及原因。

pub fn spawn_local_front_with_config<F, V>( future: F, config: TaskConfig<V>, ) -> RawResult<LocalTaskHandle<F::Output, V>, SpawnError<F, ThreadNotifier, V, LocalOutput>>
where F: Future + 'static, F::Output: 'static, V: Send + Sync + 'static,

本地队首便利派发;与spawn_local相同原值及权限,只改变下一次排队优先级。

pub fn spawn_local_front<F>( future: F, ) -> RawResult<LocalTaskHandle<F::Output>, SpawnError<F, ThreadNotifier, (), LocalOutput>>
where F: Future + 'static, F::Output: 'static,

默认附加数据(metadata)的本地队首入口,不增加F的Send/Sync/Unpin。

Trait Implementations§

§

impl<C, E, I, T> Clone for RuntimeHandle<C, E, I, T>

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<C, E, I, T> IdleDispatch for RuntimeHandle<C, E, I, T>

§

fn submit_idle(&self, task: UnsubmittedTask) -> RawResult<(), SubmitError>

向同一服务的空闲来源提交普通Send任务(Task);不检查空闲、不保证未来接纳。
§

fn idle_local_with_config<F, V>( future: F, config: TaskConfig<V>, ) -> RawResult<TaskHandle<F::Output, V>, SpawnError<F, ThreadNotifier, V>>
where F: Future + Send + 'static, F::Output: Send + 'static, V: Send + Sync + 'static,

从当前环境定位原服务后提交共享空闲来源;Future与输出要求Send,不要求Sync,不预先绑定执行线程。
Source§

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,

创建并提交空闲时任务(idle task);成功只证明来源接受,不保证执行。
Source§

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,

默认配置的空闲提交;任务(Task)未接纳前仍可按原控制能力取消。
Source§

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,

默认配置的当前空闲提交;输入保持Send约束,不等同spawn_local的本地非Send能力。
§

impl<C, E, I, T> LocalTaskDispatch for RuntimeHandle<C, E, I, T>

§

fn create_local_with_config<F, V>( future: F, config: TaskConfig<V>, ) -> RawResult<(UnsubmittedTask, LocalTaskHandle<F::Output, V>), CreateError<F, V>>
where F: Future + 'static, F::Output: 'static, V: Send + Sync + 'static,

通过当前有效本地权限创建;原Future与输出保持原线程清理,不要求Send/Sync/Unpin。失败返还原输入。
§

fn submit_local(task: UnsubmittedTask) -> RawResult<(), SubmitError>

仅在原所属线程(owner thread)的有效本地范围首次提交;错误返还同一待提交值。
Source§

fn create_local<F>( future: F, ) -> Result<(UnsubmittedTask, TaskHandle<Self::Notifier, <F as Future>::Output, (), LocalOutput>), CreateError<F, ()>>
where F: Future + 'static, <F as Future>::Output: 'static,

使用默认配置进行本地创建;无合法当前环境时明确失败,不猜测目标。
Source§

fn spawn_local_with_config<F, M>( future: F, config: TaskConfig<M>, ) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, M, LocalOutput>, SpawnError<F, Self::Notifier, M, LocalOutput>>
where F: Future + 'static, <F as Future>::Output: 'static, M: Send + Sync + 'static,

组合本地创建与本地提交;不把结果变为可跨线程,不将拒绝当成取消。
Source§

fn spawn_local<F>( future: F, ) -> Result<TaskHandle<Self::Notifier, <F as Future>::Output, (), LocalOutput>, SpawnError<F, Self::Notifier, (), LocalOutput>>
where F: Future + 'static, <F as Future>::Output: 'static,

默认配置的本地快速派发(local dispatch);不创建新线程,不内联轮询(poll)。
§

impl<C, E, I, T> RuntimeBlockOn for RuntimeHandle<C, E, I, T>

§

fn block_on<F: Future>(&self, future: F) -> F::Output

只阻塞调用线程推进这份根Future;任务服务必须由拥有者另行推动。 无Unpin/Send/Sync/’static约束,不等根派发的其它任务全部结束。

§

impl<C, E, I, T> RuntimeContext for RuntimeHandle<C, E, I, T>

§

type Handle = RuntimeHandle<C, E, I, T>

§

fn handle(&self) -> Self

取得原服务的共享句柄(shared handle);Clone不复制服务,普通释放不自动关闭。
Source§

fn try_current() -> Result<Self::Handle, CurrentRuntimeAccessError>

取得并克隆(Clone)当前所选原服务的共享句柄(shared handle),不产生本地或推进权限。 无当前目标、句柄类型(type)不匹配或线程局部存储(TLS)不可访问时返回对应错误。 有效公共选择在原服务关闭后仍可读取关闭事实,不会重新开放服务。
Source§

fn try_with_current<R>( action: impl FnOnce(&Self::Handle) -> R, ) -> Result<R, CurrentRuntimeAccessError>

同步借用不能逃逸或跨await;公共环境关闭后仍可读原关闭事实。
Source§

fn enter<R>( &self, action: impl FnOnce() -> R, ) -> Result<R, CurrentRuntimeAccessError>

同目标允许嵌套,不授予本地权限;闭包返回Future不会延长本次选择范围。
§

impl<C, E, I, T> RuntimeControl for RuntimeHandle<C, E, I, T>

§

fn request_close(&self) -> CloseRequestStatus

请求一旦记录不因通知异常回滚,无人推进也不拒绝合法请求。
§

impl<C, E, I, T> RuntimeQuery for RuntimeHandle<C, E, I, T>

§

fn id(&self) -> RuntimeId

读取原服务或任务(Task)的固定身份;不创建新身份或权限。
§

fn status(&self) -> RuntimeStatus

只读采样原服务Open/Closing/Closed;不推进服务,不保证下一次提交成功。
§

fn is_driving(&self) -> bool

查询原服务推进权当前是否实际持有;包括停放与同步钩子(hook),根专用推进不计入。
§

fn last_idle_state(&self) -> IdleState

读取最近一次成功策略判断的Unknown/Idle/NotIdle,不重新调用策略。
§

fn close_state(&self) -> CloseState

读取自洽的关闭进度样本;Completed不代表最后共享存储已释放。
§

fn external_task_count(&self) -> usize

读取已被本外部来源接收、尚未交付或合法清理的数量;与其它项独立取样。
§

fn internal_task_count(&self) -> usize

读取原内部可执行来源的数量样本;不包括纯挂起任务(Task)。
§

fn timer_registration_count(&self) -> usize

包括纯计时信号,不把每项都称为业务任务(Task)。
§

fn idle_task_count(&self) -> usize

读取空闲来源尚保管的原任务(Task)数量;不调用空闲策略。
§

fn in_flight_task_count(&self) -> usize

读取已接纳且自身退出责任未结束的任务(Task)数量;不以队列数相减推导。
§

fn waiting_for_wake_count(&self) -> usize

仅已接纳、根Pending交接完成且无唤醒/取消/退出需求者。 查询成本由具体实现公开,不承诺所有实现O(1);默认执行器(executor)实现按需O(n)扫描登记。
§

fn pending_cancel_task_count(&self) -> usize

原取消已记录但最终控制结果尚未确定;重复请求不重复计数。 查询成本由具体实现公开;默认执行器(executor)实现按需O(n)扫描,默认事件循环(event loop)不主动采集。
§

impl<C, E, I, T> RuntimeTime for RuntimeHandle<C, E, I, T>

§

type Timer = <T as ExecutorTimer>::Access

§

fn timeout(&self, duration: Duration) -> Timeout<Self::Timer> ⓘ

准备惰性计时等待;正时长首次poll才取时登记,至少1ms;零时长让出一次且不可取消。
§

fn timeout_on<F: Future>( &self, future: F, duration: Duration, ) -> TimeoutOn<Self::Timer, F> ⓘ

按业务优先组合Future与计时;不要求额外Unpin/Send/Sync/’static,完成时撤销另一等待兴趣。
§

fn sleep(&self, duration: Duration) -> Sleep<Self::Timer> ⓘ

准备短时等待;正时长范围1ms至1s,不返回独立控制句柄(handle),首次poll才开始。
§

impl<C, E, I, T> RuntimeWait for RuntimeHandle<C, E, I, T>

Source§

fn wait_one_timeout<T>( &self, duration: Duration, ) -> (WaitOneTimeout<Self::Timer, T>, OneSender<T>)

返回一次交值等待与原单发送者;通过timeout_on组合,不新增T的Send/Sync/’static/Unpin约束。
Source§

fn wait_any_timeout<T>( &self, duration: Duration, ) -> (WaitAnyTimeout<Self::Timer, T>, AnySender<T>)

返回并发竞争一次交值的等待与可克隆发送者;保留原胜者及关闭错误语义。
Source§

fn wait_all_timeout<T>( &self, duration: Duration, ) -> (WaitAllTimeout<Self::Timer, T>, AllSender<T>)

返回全部交值等待与原登记发送者;正常返回完整有序向量,超时不交部分结果。
§

impl<C, E, I, T> TaskDispatch for RuntimeHandle<C, E, I, T>

§

type Notifier = ThreadNotifier

§

fn create_with_config<F, V>( &self, future: F, config: TaskConfig<V>, ) -> RawResult<(UnsubmittedTask, TaskHandle<F::Output, V>), CreateError<F, V>>
where F: Future + Send + 'static, F::Output: Send + 'static, V: Send + Sync + 'static,

创建原服务的可跨线程任务(Task)并保留配置;不提交、不接纳、不轮询(poll)。失败返还原Future和配置。
§

fn submit(&self, task: UnsubmittedTask) -> RawResult<(), SubmitError>

向创建它的原服务提交唯一原值;明确拒绝返还原持有及原因,不取消、不改线程归属。
Source§

fn create<F>( &self, future: F, ) -> Result<(UnsubmittedTask, TaskHandle<Self::Notifier, <F as Future>::Output>), CreateError<F, ()>>
where F: Future + Send + 'static, <F as Future>::Output: Send + 'static,

使用默认配置创建;返回唯一待提交值与结果句柄(handle),不隐式派发。
Source§

fn spawn_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,

组合一次创建与提交;错误按创建/提交阶段保留对应原值,成功不表示已经执行。
Source§

fn spawn<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,

使用默认配置组合创建与提交;输入及输出只要求可跨线程转交(Send),不要求Sync或Unpin。
§

impl<C, E, I, T> TimedTaskDispatch for RuntimeHandle<C, E, I, T>

§

fn spawn_timing_with_config<F, V>( &self, future: F, delay: Duration, config: TaskConfig<V>, ) -> RawResult<TaskHandle<CoreTimedTaskNotifier<ThreadNotifier, T::Access>, F::Output, V>, SpawnError<F, CoreTimedTaskNotifier<ThreadNotifier, T::Access>, V>>
where F: Future + Send + 'static, F::Output: Send + 'static, V: Send + Sync + 'static,

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

fn spawn_timing_local_with_config<F, V>( future: F, delay: Duration, config: TaskConfig<V>, ) -> RawResult<TaskHandle<CoreTimedTaskNotifier<ThreadNotifier, T::Access>, F::Output, V, LocalOutput>, SpawnError<F, CoreTimedTaskNotifier<ThreadNotifier, T::Access>, V, LocalOutput>>
where F: Future + 'static, F::Output: 'static, V: Send + Sync + 'static,

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

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

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

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

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

Auto Trait Implementations§

§

impl<C, E = MpscTaskQueueHandle, I = MpscIdleTaskQueueHandle, T = DefaultTimerDriver<C, RuntimeTag<C>>> !RefUnwindSafe for RuntimeHandle<C, E, I, T>

§

impl<C, E = MpscTaskQueueHandle, I = MpscIdleTaskQueueHandle, T = DefaultTimerDriver<C, RuntimeTag<C>>> !UnwindSafe for RuntimeHandle<C, E, I, T>

§

impl<C, E, I, T> Forget for RuntimeHandle<C, E, I, T>

§

impl<C, E, I, T> Freeze for RuntimeHandle<C, E, I, T>
where Arc<ExecutorHandle<E, I, T, RuntimeTag<C, T>>>: Freeze,

§

impl<C, E, I, T> Move for RuntimeHandle<C, E, I, T>

§

impl<C, E, I, T> Send for RuntimeHandle<C, E, I, T>
where Arc<ExecutorHandle<E, I, T, RuntimeTag<C, T>>>: Send,

§

impl<C, E, I, T> Sync for RuntimeHandle<C, E, I, T>
where Arc<ExecutorHandle<E, I, T, RuntimeTag<C, T>>>: Sync,

§

impl<C, E, I, T> Unpin for RuntimeHandle<C, E, I, T>
where Arc<ExecutorHandle<E, I, T, RuntimeTag<C, T>>>: Unpin,

§

impl<C, E, I, T> UnsafeUnpin for RuntimeHandle<C, E, I, T>
where Arc<ExecutorHandle<E, I, T, RuntimeTag<C, T>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OpaqueAttachment for T
where T: Send + Sync + 'static,

Source§

impl<T> Runtime for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.