Skip to main content

ForegroundExecutor

Struct ForegroundExecutor 

Source
pub struct ForegroundExecutor { /* private fields */ }
Expand description

UI 主线程前景异步执行器(由 crate::engine::VeloxEngine 持有)。

Implementations§

Source§

impl ForegroundExecutor

Source

pub fn new() -> Self

创建一个绑定默认内置 NativeStdScheduler 的主线程前景异步执行器。

Source

pub fn with_backend(backend: Arc<dyn SchedulerBackend>) -> Self

创建一个绑定自定义可插拔 SchedulerBackend 的主线程前景异步执行器。

Source

pub fn set_backend(&self, backend: Arc<dyn SchedulerBackend>)

切换当前前景执行器及其派生的所有 AsyncApp 所使用的底层 SchedulerBackend。

Source

pub fn backend(&self) -> Arc<dyn SchedulerBackend> ⓘ

获取当前配置的底层 SchedulerBackend 引用。

Source

pub fn background_executor(&self) -> BackgroundExecutor

获取绑定到当前调度器后端的 BackgroundExecutor。

Source

pub fn scheduler_name(&self) -> &'static str

返回当前调度器后端名称。

Source

pub fn scheduler_capabilities(&self) -> SchedulerCapabilities

返回当前调度器能力描述符。

Source

pub fn set_wake_ui(&self, waker: impl Fn() + Send + Sync + 'static)

注入平台级唤醒回调(如 WinitUserEvent::WakeAsync / Wayland eventfd / 移动端 Looper 唤醒)。

Source

pub fn async_app(&self) -> AsyncApp

构造一个轻量 Clone 的前景协程上下文句柄 AsyncApp。

Source

pub fn spawn<T, F, Fut>(&self, f: F) -> Task<T> ⓘ
where T: 'static, F: FnOnce(AsyncApp) -> Fut, Fut: Future<Output = T> + 'static,

在 UI 主线程前景执行器上派生异步任务(接收 AsyncApp)。

Source

pub fn defer<F>(&self, f: F)
where F: FnOnce(&mut ActionScope<'_>) + 'static,

排入一个延迟到当前事件冒泡结束后在 UI 主线程执行的回调(与 GPUI cx.defer 对齐)。

Source

pub fn has_ready_work(&self) -> bool

是否存在立即待执行的前景就绪任务或延迟 defer 回调(用于判断 needs_redraw)。

Source

pub fn active_task_count(&self) -> usize

返回当前仍活跃挂载在前台执行器中的协程数量(用于测试验证取消与回收零泄漏)。

Source

pub fn poll_ready(&self, pool: &mut PodPool, now_ms: u32) -> bool

在 UI 主线程排空所有已就绪的前景协程与 defer 回调;返回是否至少推进了 1 项任务或回调。

Trait Implementations§

Source§

impl Default for ForegroundExecutor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.