pub struct AsyncRuntimeHandle { /* private fields */ }Expand description
Handle to the main-thread async runtime. Registered in app-state by
install_async and
reached from a handler via ctx.spawn_local(...)
(EventContextAsyncExt). Clone shares the
same executor (Rc); !Send — it only ever lives on the UI thread.
Implementations§
Source§impl AsyncRuntimeHandle
impl AsyncRuntimeHandle
pub fn new() -> Self
Sourcepub fn poll_source(&self) -> Rc<Cell<bool>>
pub fn poll_source(&self) -> Rc<Cell<bool>>
The shared poll flag passed to on_loop_tick; set while the executor
wants continuous polling (a task re-woke synchronously), cleared when
idle so the loop can sleep.
Sourcepub fn completions(&self) -> AsyncCompletionHandle
pub fn completions(&self) -> AsyncCompletionHandle
The completion registry shared with teksilo-app so it can deliver
spawn_local_with results with a fresh
EventContext. Registered in app-state under
AsyncCompletionHandle.
Sourcepub fn set_poster(&self, poster: Arc<dyn AppEventPoster>)
pub fn set_poster(&self, poster: Arc<dyn AppEventPoster>)
Install the event-loop poster used as the cross-thread wake target and
to post completions. Idempotent (set once). Called lazily on the first
spawn from ctx.poster().
Sourcepub fn tick(&self) -> bool
pub fn tick(&self) -> bool
Advance the executor by one turn: poll every live task that a wake made
runnable, dropping completed/cancelled ones. Returns true if it
polled tasks (the caller repaints). Normally driven by the on_loop_tick
hook; exposed for headless drivers and tests.
Sourcepub fn spawn_local(
&self,
future: impl Future<Output = ()> + 'static,
) -> TaskHandle
pub fn spawn_local( &self, future: impl Future<Output = ()> + 'static, ) -> TaskHandle
Spawn a !Send future on the main-thread executor. The future may
capture and mutate Signals and other Rc handles directly. Returns a
TaskHandle: drop to cancel, .detach() to fire-and-forget.
Sourcepub fn spawn_local_with<R: 'static>(
&self,
window_id: TeksiloWindowId,
future: impl Future<Output = R> + 'static,
on_complete: impl FnOnce(R, &mut EventContext<'_>) + 'static,
) -> TaskHandle
pub fn spawn_local_with<R: 'static>( &self, window_id: TeksiloWindowId, future: impl Future<Output = R> + 'static, on_complete: impl FnOnce(R, &mut EventContext<'_>) + 'static, ) -> TaskHandle
Spawn a future whose result is delivered to on_complete with a fresh
EventContext bound to window_id’s tree — the supported way to run
a one-shot ambient op (open_window, send_intent, …) after await.
The future body itself runs handle-only (no EventContext).
Trait Implementations§
Source§impl Clone for AsyncRuntimeHandle
impl Clone for AsyncRuntimeHandle
Source§fn clone(&self) -> AsyncRuntimeHandle
fn clone(&self) -> AsyncRuntimeHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AsyncRuntimeHandle
impl !Send for AsyncRuntimeHandle
impl !Sync for AsyncRuntimeHandle
impl !UnwindSafe for AsyncRuntimeHandle
impl Freeze for AsyncRuntimeHandle
impl Unpin for AsyncRuntimeHandle
impl UnsafeUnpin for AsyncRuntimeHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more