Skip to main content

Scope

Struct Scope 

Source
pub struct Scope<'scope, 'env>
where 'env: 'scope,
{ /* private fields */ }
Expand description

Borrowing scope for spawning parallel sub-tasks that may capture non-'static references.

Created by scope. Each Scope::spawn call registers a job on the unified scheduler; the scope blocks until every spawned job has completed before the body closure returns, so borrowed data cannot escape the scope.

This is the Rayon-style scope shape, adapted to Moirai’s unified hybrid scheduler. Unlike join, which forks exactly two branches, scope allows an arbitrary number of sub-tasks to be spawned and joined within a single region.

Implementations§

Source§

impl<'scope, 'env> Scope<'scope, 'env>
where 'env: 'scope,

Source

pub fn spawn<F>(&self, task: F)
where F: FnOnce() + Send + 'env,

Spawn a parallel sub-task within this scope.

The task may borrow values that outlive the scope call. The scope waits for every spawned task before returning, so borrowed data cannot escape. A task the scheduler’s admission queue turns away runs on the calling thread instead, so backpressure costs parallelism rather than the task.

§Panics

Panics if the underlying scheduler refuses to register the task, which registration itself does not do — the failure surfaces from scope when the scheduler is shutting down.

Auto Trait Implementations§

§

impl<'scope, 'env> !RefUnwindSafe for Scope<'scope, 'env>

§

impl<'scope, 'env> !Send for Scope<'scope, 'env>

§

impl<'scope, 'env> !Sync for Scope<'scope, 'env>

§

impl<'scope, 'env> !UnwindSafe for Scope<'scope, 'env>

§

impl<'scope, 'env> Freeze for Scope<'scope, 'env>

§

impl<'scope, 'env> Unpin for Scope<'scope, 'env>

§

impl<'scope, 'env> UnsafeUnpin for Scope<'scope, 'env>

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.