pub struct TaskContext { /* private fields */ }
Expand description
The context arguments which are available to background tasks spawned onto the
TokioTasksRuntime
.
Implementations§
Source§impl TaskContext
impl TaskContext
Sourcepub fn current_tick(&self) -> usize
pub fn current_tick(&self) -> usize
Returns the current value of the ticket count from the main thread - how many updates have occurred since the start of the program. Because the tick count is updated from the main thread, the tick count may change any time after this function call returns.
Sourcepub async fn sleep_updates(&mut self, updates_to_sleep: usize)
pub async fn sleep_updates(&mut self, updates_to_sleep: usize)
Sleeps the background task until a given number of main thread updates have occurred. If you instead want to sleep for a given length of wall-clock time, call the normal Tokio sleep function.
Sourcepub async fn run_on_main_thread<Runnable, Output>(
&mut self,
runnable: Runnable,
) -> Output
pub async fn run_on_main_thread<Runnable, Output>( &mut self, runnable: Runnable, ) -> Output
Invokes a synchronous callback on the main Bevy thread. The callback will have mutable access to the
main Bevy World
, allowing it to update any resources or entities that it wants. The callback can
report results back to the background thread by returning an output value, which will then be returned from
this async function once the callback runs.
Trait Implementations§
Source§impl Clone for TaskContext
impl Clone for TaskContext
Source§fn clone(&self) -> TaskContext
fn clone(&self) -> TaskContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for TaskContext
impl RefUnwindSafe for TaskContext
impl Send for TaskContext
impl Sync for TaskContext
impl Unpin for TaskContext
impl UnwindSafe for TaskContext
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
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.