Skip to main content

DefaultExecutor

Struct DefaultExecutor 

Source
pub struct DefaultExecutor<C, E, I, T, L>{ /* private fields */ }
Expand description

供运行时(runtime)实现者静态组合的完整机制;本对象!Send/!Sync,不创建线程。 外部提供当前线程,创建后固定所属域。公开业务由更外层简洁类型包装,不暴露类型链。 释放(drop)停止接纳并交还原来源与本地任务(Task)责任;仍存活动可延迟本地实际退出。 上层运行时(runtime)须先撤本地权限;共享访问晚释放不成为原异步计算(Future)清理前提。 清理失败保持已关闭不可用与未完成确认,不重新执行原值或报告成功完成。

Implementations§

Source§

impl<C, E, I, T, L> DefaultExecutor<C, E, I, T, L>

Source

pub fn new( clock: C, external: E, idle: I, options: ExecutorOptions, make_timer: impl FnOnce(RuntimeId, &C, ThreadNotifier) -> Result<T>, ) -> Result<Self>

接管新建的私有普通/空闲管理对象,在本线程新建原所属域。 make_timer取得最终RuntimeId、同一clock及原线程通知,必须返回同源新拥有者。 原来源应未公开业务访问;构造失败合法释放已接管资源,不初始化全局时钟。

Examples found in repository?
examples/executor_bounds.rs (lines 41-47)
39fn declarations(clock: ManualClock, external: MpscTaskQueue, idle: MpscIdleTaskQueue) {
40    send_sync::<Shared>();
41    let _: pi_result::Result<Service> = Service::new(
42        clock,
43        external,
44        idle,
45        ExecutorOptions::default(),
46        |id, clock, notify| Timer::new(id, *clock, notify, CancelTimerOptions::default()),
47    );
48}
Source

pub fn handle(&self) -> ExecutorHandle<E::Handle, I::Handle, T, L>

Source

pub fn local(&self) -> &Rc<ExecutorLocal<T>>

框架本地权限注册目标,只供运行时(runtime)装配;最终业务不得取得它。

Source

pub fn begin_drive(&self) -> DriveLease

核当前线程并独占标记;重复推进在用户Future首次poll前panic。 本函数不进入全局DriveScope,供block_on核心自身统一建立该范围。

Source

pub fn run_once<A: AdmissionRule, P: IdlePolicy, H: ExecutorHooks>( &mut self, admission: &A, policy: &mut P, hooks: &mut H, ) -> Result<TurnResult>

一次有限轮转,不停放线程、不等新任务。用户Future、Drop或控制hook可同步阻塞。 最多One到期/内部/空闲各一次业务run机会;有限批次直接清理另算。 All到期业务按序转内部,不逐项内联poll;已取消/退出者不隐式admit。

Source

pub fn run<A: AdmissionRule, P: IdlePolicy, H: ExecutorHooks>( &mut self, admission: &A, policy: &mut P, hooks: &mut H, ) -> Result<()>

持续推进至服务关闭;外部提交、已有唤醒、取消/关闭及超时均可使停放返回。

Source

pub fn turn_with_lease<A: AdmissionRule, P: IdlePolicy, H: ExecutorHooks>( &mut self, lease: &DriveLease, admission: &A, policy: &mut P, hooks: &mut H, ) -> Result<TurnResult>

已合法取得本次DriveLease的内部轮转;不再次进入DriveScope,不为block_on制造嵌套。

Source

pub fn park_with_lease<A: AdmissionRule>( &mut self, lease: &DriveLease, admission: &A, last: &TurnResult, root: Option<&RootWakeState>, ) -> Result<()>

用上次策略建议重新核工作、通知与定时上界;root仅用于同步根的额外通知。 返回前若通知已消费必须实际重新轮询,不能以旧snapshot继续停放。

Trait Implementations§

Source§

impl<C, E, I, T, L> Drop for DefaultExecutor<C, E, I, T, L>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<C, E, I, T, L> !RefUnwindSafe for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> !Send for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> !Sync for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> !UnwindSafe for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> Forget for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> Freeze for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> Move for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> Unpin for DefaultExecutor<C, E, I, T, L>

§

impl<C, E, I, T, L> UnsafeUnpin for DefaultExecutor<C, 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> 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, 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.