Struct bevy_tasks::IoTaskPool
source · [−]pub struct IoTaskPool(_);
Expand description
A newtype for a task pool for IO-intensive work (i.e. tasks that spend very little time in a “woken” state)
Implementations
sourceimpl IoTaskPool
impl IoTaskPool
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 Debug for IoTaskPool
impl Debug for IoTaskPool
Auto Trait Implementations
impl !RefUnwindSafe for IoTaskPool
impl Send for IoTaskPool
impl Sync for IoTaskPool
impl Unpin for IoTaskPool
impl !UnwindSafe for IoTaskPool
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