pub struct Running(/* private fields */);Expand description
Work running off the main thread for its entity, such as a tool call’s
work: when
it finishes, the kernel replaces it with its output in PollTasks, as a
Done<T> or the component Running::spawn_into names, and
observers of that component carry on. Bevy’s own pattern
(examples/async_tasks/async_compute.rs): one task component for every
kind of output, so no plugin registers a system for its own. Dropping
it, or the entity, cancels the task; so does the app’s exit.
Implementations§
Source§impl Running
impl Running
Sourcepub fn spawn<T: Send + Sync + 'static>(
pool: &TaskPool,
wake: &Wake,
work: impl ConditionalSendFuture<Output = T> + 'static,
) -> Self
pub fn spawn<T: Send + Sync + 'static>( pool: &TaskPool, wake: &Wake, work: impl ConditionalSendFuture<Output = T> + 'static, ) -> Self
Spawns work on pool; it ends as a Done<T> on the entity, and
wakes the loop.
Sourcepub fn spawn_into<C: Component + From<T>, T: Send + 'static>(
pool: &TaskPool,
wake: &Wake,
work: impl ConditionalSendFuture<Output = T> + 'static,
) -> Self
pub fn spawn_into<C: Component + From<T>, T: Send + 'static>( pool: &TaskPool, wake: &Wake, work: impl ConditionalSendFuture<Output = T> + 'static, ) -> Self
Running::spawn, ending as the component C made from the
output.
Sourcepub fn answering<T: Into<Outcome> + Send + 'static>(
pool: &TaskPool,
wake: &Wake,
work: impl ConditionalSendFuture<Output = T> + 'static,
) -> Self
pub fn answering<T: Into<Outcome> + Send + 'static>( pool: &TaskPool, wake: &Wake, work: impl ConditionalSendFuture<Output = T> + 'static, ) -> Self
Spawns work on pool for the effect it goes on, such as an open
tool call’s ToolResult; it ends as the effect’s
stage::Outcome, unless something answered it first.
Sourcepub fn stream<T: Send + Sync + 'static>(
pool: &TaskPool,
wake: &Wake,
items: impl Stream<Item = T> + ConditionalSend + 'static,
) -> Self
pub fn stream<T: Send + Sync + 'static>( pool: &TaskPool, wake: &Wake, items: impl Stream<Item = T> + ConditionalSend + 'static, ) -> Self
Spawns a task on pool that runs items to their end, such as a
socket’s messages or a thread’s channel: each item is inserted on
the entity as a Done<T>, in order, and wakes the loop; once the
last one is in, Running is removed. Several items may come in one
frame, so a reader observes Insert<Done<T>>, which sees each.
Sourcepub fn is_stream(&self) -> bool
pub fn is_stream(&self) -> bool
Whether it is a Running::stream, a source that may never end,
rather than work that finishes.
Trait Implementations§
Source§impl Component for Running
impl Component for Running
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§const HAS_SUMMARY_TICK: bool = false
const HAS_SUMMARY_TICK: bool = false
Auto Trait Implementations§
impl Freeze for Running
impl RefUnwindSafe for Running
impl Send for Running
impl Sync for Running
impl Unpin for Running
impl UnsafeUnpin for Running
impl UnwindSafe for Running
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<T> ConditionalSend for Twhere
T: Send,
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>, which can then be
downcast into Box<dyn 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>, which 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.