Struct TaskPool

Source
pub struct TaskPool<'s, T>(/* private fields */);
Expand description

A Bevy SystemParam to execute many similar AsyncTasks in the background simultaneously.

Implementations§

Source§

impl<T: ConditionalSend + 'static> TaskPool<'_, T>

Source

pub fn is_idle(&self) -> bool

Returns whether the task pool is idle.

Source

pub fn spawn(&mut self, task: impl Into<AsyncTask<T>>)

Spawn an async task in the background.

Source

pub fn iter_poll(&mut self) -> impl Iterator<Item = Poll<T>>

Iterate and poll the task pool for the current task statuses.

Trait Implementations§

Source§

impl<'s, T: Debug> Debug for TaskPool<'s, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Send + 'static> ExclusiveSystemParam for TaskPool<'_, T>

Source§

type State = SyncCell<Vec<AsyncReceiver<T>>>

Used to store data which persists across invocations of a system.
Source§

type Item<'s> = TaskPool<'s, T>

The item type returned when constructing this system param. See SystemParam::Item.
Source§

fn init(_world: &mut World, _system_meta: &mut SystemMeta) -> Self::State

Creates a new instance of this param’s State.
Source§

fn get_param<'s>( state: &'s mut Self::State, _system_meta: &SystemMeta, ) -> Self::Item<'s>

Creates a parameter to be passed into an ExclusiveSystemParamFunction.
Source§

impl<T: Send + 'static> SystemParam for TaskPool<'_, T>

Source§

type State = SyncCell<Vec<AsyncReceiver<T>>>

Used to store data which persists across invocations of a system.
Source§

type Item<'w, 's> = TaskPool<'s, T>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more
Source§

fn init_state(_world: &mut World, _system_meta: &mut SystemMeta) -> Self::State

Registers any World access used by this SystemParam and creates a new instance of this param’s State.
Source§

unsafe fn get_param<'w, 's>( state: &'s mut Self::State, _system_meta: &SystemMeta, _world: UnsafeWorldCell<'w>, _change_tick: Tick, ) -> Self::Item<'w, 's>

Creates a parameter to be passed into a SystemParamFunction. Read more
Source§

unsafe fn new_archetype( state: &mut Self::State, archetype: &Archetype, system_meta: &mut SystemMeta, )

For the specified Archetype, registers the components accessed by this SystemParam (if applicable).a Read more
Source§

fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)

Applies any deferred mutations stored in this SystemParam’s state. This is used to apply Commands during ApplyDeferred.
Source§

fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )

Queues any deferred mutations to be applied at the next ApplyDeferred.
Source§

unsafe fn validate_param( state: &Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'_>, ) -> Result<(), SystemParamValidationError>

Validates that the param can be acquired by the get_param. Read more
Source§

impl<T: Send + 'static> ReadOnlySystemParam for TaskPool<'_, T>

Auto Trait Implementations§

§

impl<'s, T> Freeze for TaskPool<'s, T>

§

impl<'s, T> !RefUnwindSafe for TaskPool<'s, T>

§

impl<'s, T> Send for TaskPool<'s, T>
where T: Send,

§

impl<'s, T> Sync for TaskPool<'s, T>
where T: Send,

§

impl<'s, T> Unpin for TaskPool<'s, T>

§

impl<'s, T> !UnwindSafe for TaskPool<'s, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ConditionalSend for T
where T: Send,