Struct bevy::tasks::TaskPool[]

pub struct TaskPool { /* fields omitted */ }

A thread pool for executing tasks. Tasks are futures that are being automatically driven by the pool on threads owned by the pool.

Implementations

impl TaskPool

pub fn new() -> TaskPool

Create a TaskPool with the default configuration.

pub fn thread_num(&self) -> usize

Return the number of threads owned by the task pool

pub fn scope<'scope, F, T>(&self, f: F) -> Vec<T, Global>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator
where
    T: Send + 'static,
    F: FnOnce(&mut Scope<'scope, T>) + 'scope + Send

Allows spawning non-`static futures on the thread pool. The function takes a callback, passing a scope object into it. The scope object provided to the callback can be used to spawn tasks. This function will await the completion of all tasks before returning.

This is similar to rayon::scope and crossbeam::scope

pub fn spawn<T>(
    &self,
    future: impl Future<Output = T> + Send + 'static
) -> Task<T>

Notable traits for Task<T>

impl<T> Future for Task<T> type Output = T;
where
    T: Send + 'static, 

Spawns a static future onto the thread pool. The returned Task is a future. It can also be cancelled and “detached” allowing it to continue running without having to be polled by the end-user.

pub fn spawn_local<T>(
    &self,
    future: impl Future<Output = T> + 'static
) -> Task<T>

Notable traits for Task<T>

impl<T> Future for Task<T> type Output = T;
where
    T: 'static, 

Trait Implementations

impl Clone for TaskPool

impl Debug for TaskPool

impl Default for TaskPool

Auto Trait Implementations

impl !RefUnwindSafe for TaskPool

impl Send for TaskPool

impl Sync for TaskPool

impl Unpin for TaskPool

impl !UnwindSafe for TaskPool

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Any + Clone

impl<T> Component for T where
    T: 'static + Send + Sync

impl<T> Downcast for T where
    T: Any

impl<T> Downcast<T> for T

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> From<T> for T[src]

impl<T> FromWorld for T where
    T: Default

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> TypeData for T where
    T: 'static + Send + Sync + Clone

impl<T> Upcast<T> for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,