pub struct AsyncScope(/* private fields */);Expand description
Local lifetime controller. Cancellation revokes descendants before requesting task abortion. Keep a component’s scope from its mount context when handlers later receive contexts for child controls.
ⓘ
use pax_runtime_api::{application::{ApplicationInstance, AppOptions}, TargetInfo};
let app = ApplicationInstance::prepare(TargetInfo::default(), AppOptions::default()).unwrap();
let scope = app.context().async_scope().unwrap();
std::thread::spawn(move || scope.cancel());Implementations§
Source§impl AsyncScope
impl AsyncScope
pub fn id(&self) -> u64
pub fn is_closed(&self) -> bool
Sourcepub fn child(&self) -> Result<AsyncScope, AsyncError>
pub fn child(&self) -> Result<AsyncScope, AsyncError>
Create an independent operation underneath this lifetime.
pub fn cancel(&self)
Sourcepub fn replace<T>(
&self,
previous: &mut Option<AsyncScope>,
property: &Property<T>,
initial: T,
) -> Result<AsyncScope, AsyncError>where
T: SharedPropertyValue,
pub fn replace<T>(
&self,
previous: &mut Option<AsyncScope>,
property: &Property<T>,
initial: T,
) -> Result<AsyncScope, AsyncError>where
T: SharedPropertyValue,
Revoke the previous request before publishing replacement state and creating its new operation. Registration failure leaves the old work closed.
pub fn publisher<T>(
&self,
property: &Property<T>,
) -> Result<GuardedPublisher<T>, AsyncError>where
T: SharedPropertyValue,
pub fn completion<T>(
&self,
callback: impl FnOnce(T) + 'static,
) -> Result<Completion<T>, AsyncError>where
T: Send + 'static,
pub fn channel<T>(
&self,
capacity: usize,
callback: impl FnMut(T) + 'static,
) -> Result<(UiSender<T>, UiSubscription), AsyncError>where
T: Send + 'static,
pub fn default_channel<T>(
&self,
callback: impl FnMut(T) + 'static,
) -> Result<(UiSender<T>, UiSubscription), AsyncError>where
T: Send + 'static,
Sourcepub fn register_task(
&self,
start: impl FnOnce(TaskReporter) -> Box<dyn FnOnce()> + 'static,
) -> Result<TaskControl, AsyncError>
pub fn register_task( &self, start: impl FnOnce(TaskReporter) -> Box<dyn FnOnce()> + 'static, ) -> Result<TaskControl, AsyncError>
Adapter entry point. start runs only after activation and returns a
nonblocking cancellation request. Retaining the control is optional.
Trait Implementations§
Source§impl Clone for AsyncScope
impl Clone for AsyncScope
Source§fn clone(&self) -> AsyncScope
fn clone(&self) -> AsyncScope
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AsyncScope
impl !Send for AsyncScope
impl !Sync for AsyncScope
impl !UnwindSafe for AsyncScope
impl Freeze for AsyncScope
impl Unpin for AsyncScope
impl UnsafeUnpin for AsyncScope
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.