Skip to main content

ExecutorHandle

Struct ExecutorHandle 

pub struct ExecutorHandle<E: ExternalTaskQueue + Clone, I: IdleTaskQueue + Clone, T: ExecutorTimer + 'static, L: LocalReadySubmit> { /* private fields */ }
Expand description

支持Clone+Send+Sync;T/L仅静态类型映射,不把本地拥有者装进共享存储。 不公开工厂(factory)、队列(queue)句柄或管理权限;不能推进服务。 waiting_for_wake_count及pending_cancel_task_count按需O(n)扫描已登记任务(Task), n为当前可观察登记规模;两项独立取样,不承诺全局同一瞬间,默认事件循环(event loop)不主动调用。

Implementations§

§

impl<E: ExternalTaskQueue + Clone, I: IdleTaskQueue + Clone, T: ExecutorTimer + 'static, L: LocalReadySubmit> ExecutorHandle<E, I, T, L>

pub fn timer_access(&self) -> T::Access

取得原服务计时抽象,不暴露队列管理或强本地持有。

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

创建后先登记基本查询,再导出原值;创建本身不要求服务推进,也不隐式提交。 普通创建可在服务结束后成功,后续提交仍明确拒绝;不重新开放服务。

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

将本服务普通创建的原值提交至普通外部来源,不要求当前正在推进服务。 错误保留同一UnsubmittedTask与原原因;本地创建值须走本地入口,关闭服务拒绝新提交。 成功只确认来源接收并安排通知,不保证已经接纳或轮询(poll)。

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

将本服务普通创建的Send任务(Task)交给空闲来源,不保证空闲发生、首次接纳或执行。 关闭、错服务或错误创建方式等明确拒绝时返还同一原值及原因,不改变已有取消事实。

pub fn create_local<F, M>( &self, local: &ExecutorLocal<T>, future: F, config: TaskConfig<M>, ) -> RawResult<(UnsubmittedTask, TaskHandle<ThreadNotifier, F::Output, M, LocalOutput>), CreateError<F, M>>
where F: Future + 'static, F::Output: 'static, M: Send + Sync + 'static,

由上层已核同一当前权限的本地设施提供;本函数仍核RuntimeId,不替外线程借owner。

pub fn submit_local( &self, local: &ExecutorLocal<T>, task: UnsubmittedTask, ) -> RawResult<(), SubmitError>

使用同一原服务、原所属域且有效的本地设施,将本地创建值放入内部队尾。 错服务、错所属域、失效或队列拒绝均返还同一原值及原因,不回退到外部来源。 提交不隐式接纳、轮询(poll)或取消;普通创建值须走普通入口。

pub fn submit_local_front( &self, local: &ExecutorLocal<T>, task: UnsubmittedTask, ) -> RawResult<(), SubmitError>

原线程首次提交到内部头;只改变下一次选取,不抢断当前Future或绕过接纳/取消规则。

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

同步创建并提交本服务定时任务(Task),delay从本次提交准备取时,零时长也真实登记。 delay允许0或至少1ms,无sleep的1s固定上限,但仍须满足原时钟与截止时间的可表示范围。 准备或创建失败返还原异步计算(Future)与配置;明确提交拒绝保留待提交原值及结果句柄(handle)。 成功仅确认定时来源接收,截止后仍由原服务接纳/推进,不保证按墙钟时间立即执行。

pub fn spawn_timing_local<F, M>( &self, local: &ExecutorLocal<T>, future: F, delay: Duration, config: TaskConfig<M>, ) -> RawResult<TaskHandle<TimedTaskNotifier<ThreadNotifier, T::Access>, F::Output, M, LocalOutput>, SpawnError<F, TimedTaskNotifier<ThreadNotifier, T::Access>, M, LocalOutput>>
where F: Future + 'static, F::Output: 'static, M: Send + Sync + 'static,

在同服务、原所属域及有效本地权限中同步创建并提交定时任务(Task),不要求F或输出Send/Sync。 delay沿spawn_timing的0或至少1ms规则,无1s固定上限,仍须满足截止时间可表示范围。 计时、零时长及分阶段错误返还沿普通定时派发约定;本地输出仍限原所属线程(owner thread)。 缺少合法本地能力时保留原输入和原因,不转投其它服务或跨线程处理原异步计算(Future)。

Trait Implementations§

§

impl<E: ExternalTaskQueue + Clone, I: IdleTaskQueue + Clone, T: ExecutorTimer + 'static, L: LocalReadySubmit> Clone for ExecutorHandle<E, I, T, L>

§

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<E: ExternalTaskQueue + Clone, I: IdleTaskQueue + Clone, T: ExecutorTimer + 'static, L: LocalReadySubmit> RuntimeControl for ExecutorHandle<E, I, T, L>

§

fn request_close(&self) -> CloseRequestStatus

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

impl<E: ExternalTaskQueue + Clone, I: IdleTaskQueue + Clone, T: ExecutorTimer + 'static, L: LocalReadySubmit> RuntimeQuery for ExecutorHandle<E, I, T, L>

§

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)不主动采集。

Auto Trait Implementations§

§

impl<E, I, T, L> !RefUnwindSafe for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> !UnwindSafe for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> Forget for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> Freeze for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> Move for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> Send for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> Sync for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> Unpin for ExecutorHandle<E, I, T, L>

§

impl<E, I, T, L> UnsafeUnpin for ExecutorHandle<E, I, T, L>

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> 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.