Skip to main content

Executor

Enum Executor 

Source
pub enum Executor {
    Pool(ThreadPool),
    Delegating(DelegatingExecutor),
}
Expand description

一个执行器。

用 enum 而不是 Box<dyn Executor>:dispatch_task 在热路径上 (schedule_node 的 while try_claim 每轮都调一次),静态分发省掉虚表; 而且「关停 + join 必须发生在动节点之前」这条约定要看得清具体类型。

Variants§

§

Pool(ThreadPool)

拥有自己工作线程的线程池(YAML type: "ThreadPoolExecutor")。

§

Delegating(DelegatingExecutor)

不拥有线程,交还宿主线程(YAML type: "DelegatingExecutor")。

Implementations§

Source§

impl Executor

Source

pub fn name(&self) -> &str

Source

pub fn is_delegating(&self) -> bool

是否把任务交还宿主线程(而不是自有工作线程)。

Source

pub fn num_threads(&self) -> usize

自有工作线程数。委托执行器返回 0 —— 它一个线程都不拥有。

Source

pub fn affinity(&self) -> &[usize]

CPU 亲和力核列表(空 = 不绑)。仅用于内省 / 可视化。

Source

pub fn priority(&self) -> i32

实时优先级(0 = 普通分时)。仅用于内省 / 可视化。

Source

pub fn start(&self, graph: Weak<GraphInner>)

拉起工作线程。委托执行器是 no-op:宿主线程早就在跑,不由引擎创建。

Source

pub fn submit(&self, node: NodeId) -> bool

投递一个就绪节点。返回 false 表示没收下,调用方须善后(撤销已取得的令牌)。

Source

pub fn submit_source_wake( &self, node: NodeId, generation: u64, delay: Duration, ) -> bool

Source

pub fn pending(&self) -> usize

Source

pub fn shutdown(&self)

关停并 join。幂等。委托执行器是 no-op(无线程可 join)。

Source

pub fn take_delegated(&self) -> Option<NodeId>

弹一个待宿主执行的任务;线程池恒返回 None(它的任务由自己的 worker 取)。

Source

pub fn complete_delegated(&self, execution: Option<Duration>)

Source

pub fn clear_delegated(&self)

清空待宿主执行的队列(reset 用);线程池是 no-op。

Source

pub fn reset_run_state(&self)

Source

pub fn clear_delayed(&self)

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.