Struct bevy_tasks::Scope
source · [−]pub struct Scope<'scope, T> { /* private fields */ }
Expand description
A TaskPool
scope for running one or more non-'static
futures.
For more information, see TaskPool::scope
.
Implementations
sourceimpl<'scope, T: Send + 'scope> Scope<'scope, T>
impl<'scope, T: Send + 'scope> Scope<'scope, T>
sourcepub fn spawn<Fut: Future<Output = T> + 'scope + Send>(&mut self, f: Fut)
pub fn spawn<Fut: Future<Output = T> + 'scope + Send>(&mut self, f: Fut)
Spawns a scoped future onto the thread pool. The scope must outlive
the provided future. The results of the future will be returned as a part of
TaskPool::scope
’s return value.
If the provided future is non-Send
, Scope::spawn_local
should be used
instead.
For more information, see TaskPool::scope
.
sourcepub fn spawn_local<Fut: Future<Output = T> + 'scope>(&mut self, f: Fut)
pub fn spawn_local<Fut: Future<Output = T> + 'scope>(&mut self, f: Fut)
Spawns a scoped future onto the thread-local executor. The scope must outlive
the provided future. The results of the future will be returned as a part of
TaskPool::scope
’s return value. Users should generally prefer to use
Scope::spawn
instead, unless the provided future is not Send
.
For more information, see TaskPool::scope
.
Trait Implementations
Auto Trait Implementations
impl<'scope, T> RefUnwindSafe for Scope<'scope, T>
impl<'scope, T> !Send for Scope<'scope, T>
impl<'scope, T> !Sync for Scope<'scope, T>
impl<'scope, T> Unpin for Scope<'scope, T>
impl<'scope, T> UnwindSafe for Scope<'scope, T>
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