pub struct ForegroundExecutor { /* private fields */ }Expand description
UI 主线程前景异步执行器(由 crate::engine::VeloxEngine 持有)。
Implementations§
Source§impl ForegroundExecutor
impl ForegroundExecutor
Sourcepub fn new() -> Self
pub fn new() -> Self
创建一个绑定默认内置 NativeStdScheduler 的主线程前景异步执行器。
Sourcepub fn with_backend(backend: Arc<dyn SchedulerBackend>) -> Self
pub fn with_backend(backend: Arc<dyn SchedulerBackend>) -> Self
创建一个绑定自定义可插拔 SchedulerBackend 的主线程前景异步执行器。
Sourcepub fn set_backend(&self, backend: Arc<dyn SchedulerBackend>)
pub fn set_backend(&self, backend: Arc<dyn SchedulerBackend>)
切换当前前景执行器及其派生的所有 AsyncApp 所使用的底层 SchedulerBackend。
Sourcepub fn backend(&self) -> Arc<dyn SchedulerBackend> ⓘ
pub fn backend(&self) -> Arc<dyn SchedulerBackend> ⓘ
获取当前配置的底层 SchedulerBackend 引用。
Sourcepub fn background_executor(&self) -> BackgroundExecutor
pub fn background_executor(&self) -> BackgroundExecutor
获取绑定到当前调度器后端的 BackgroundExecutor。
Sourcepub fn scheduler_name(&self) -> &'static str
pub fn scheduler_name(&self) -> &'static str
返回当前调度器后端名称。
Sourcepub fn scheduler_capabilities(&self) -> SchedulerCapabilities
pub fn scheduler_capabilities(&self) -> SchedulerCapabilities
返回当前调度器能力描述符。
Sourcepub fn set_wake_ui(&self, waker: impl Fn() + Send + Sync + 'static)
pub fn set_wake_ui(&self, waker: impl Fn() + Send + Sync + 'static)
注入平台级唤醒回调(如 WinitUserEvent::WakeAsync / Wayland eventfd / 移动端 Looper 唤醒)。
Sourcepub fn defer<F>(&self, f: F)where
F: FnOnce(&mut ActionScope<'_>) + 'static,
pub fn defer<F>(&self, f: F)where
F: FnOnce(&mut ActionScope<'_>) + 'static,
排入一个延迟到当前事件冒泡结束后在 UI 主线程执行的回调(与 GPUI cx.defer 对齐)。
Sourcepub fn has_ready_work(&self) -> bool
pub fn has_ready_work(&self) -> bool
是否存在立即待执行的前景就绪任务或延迟 defer 回调(用于判断 needs_redraw)。
Sourcepub fn active_task_count(&self) -> usize
pub fn active_task_count(&self) -> usize
返回当前仍活跃挂载在前台执行器中的协程数量(用于测试验证取消与回收零泄漏)。
Sourcepub fn poll_ready(&self, pool: &mut PodPool, now_ms: u32) -> bool
pub fn poll_ready(&self, pool: &mut PodPool, now_ms: u32) -> bool
在 UI 主线程排空所有已就绪的前景协程与 defer 回调;返回是否至少推进了 1 项任务或回调。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ForegroundExecutor
impl !Send for ForegroundExecutor
impl !Sync for ForegroundExecutor
impl !UnwindSafe for ForegroundExecutor
impl Forget for ForegroundExecutor
impl Freeze for ForegroundExecutor
impl Move for ForegroundExecutor
impl Unpin for ForegroundExecutor
impl UnsafeUnpin for ForegroundExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
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
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
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。