Struct bevy_tasks::AsyncComputeTaskPool
source · [−]pub struct AsyncComputeTaskPool(pub TaskPool);
Expand description
A newtype for a task pool for CPU-intensive work that may span across multiple frames
Tuple Fields
0: TaskPool
Methods from Deref<Target = TaskPool>
sourcepub fn thread_num(&self) -> usize
pub fn thread_num(&self) -> usize
Return the number of threads owned by the task pool
sourcepub fn scope<'scope, F, T>(&self, f: F) -> Vec<T> where
F: FnOnce(&mut Scope<'scope, T>) + 'scope + Send,
T: Send + 'static,
pub fn scope<'scope, F, T>(&self, f: F) -> Vec<T> where
F: FnOnce(&mut Scope<'scope, T>) + 'scope + Send,
T: Send + 'static,
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
sourcepub 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,
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.
If the provided future is non-Send
, TaskPool::spawn_local
should be used instead.
sourcepub 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,
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,
Spawns a static future on the thread-local async executor for the current thread. The task
will run entirely on the thread the task was spawned on. 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. Users should generally prefer to use TaskPool::spawn
instead, unless the provided future is not Send
.
Trait Implementations
sourceimpl Clone for AsyncComputeTaskPool
impl Clone for AsyncComputeTaskPool
sourcefn clone(&self) -> AsyncComputeTaskPool
fn clone(&self) -> AsyncComputeTaskPool
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AsyncComputeTaskPool
impl Debug for AsyncComputeTaskPool
Auto Trait Implementations
impl !RefUnwindSafe for AsyncComputeTaskPool
impl Send for AsyncComputeTaskPool
impl Sync for AsyncComputeTaskPool
impl Unpin for AsyncComputeTaskPool
impl !UnwindSafe for AsyncComputeTaskPool
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more