Skip to main content

SchedulerScope

Struct SchedulerScope 

Source
pub struct SchedulerScope<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize = 256, const SPIN_LIMIT: usize = 8192>
where C: WorkClass,
{ /* private fields */ }
Expand description

Borrowing scope for scheduler jobs that must complete before the scope exits.

Implementations§

Source§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize, const SPIN_LIMIT: usize> SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>
where C: WorkClass,

Source

pub fn spawn<F>(&self, task: F) -> Result<(), ExecutorError>
where F: FnOnce(usize) + Send + 'scope,

Spawn a job into this scope.

The job may borrow values that outlive the scope call. Scoped jobs are coalesced into worker-sized scheduler batches and complete before ThreadScheduler::scope returns. Jobs are not guaranteed to start while the scope body is still registering work.

The usize the job receives identifies the lane running it. Worker lanes are 0..worker_count(); a job the admission queue turned away runs on the calling lane, identified as worker_count(). It is a lane identity, not an index into the worker set.

Source

pub fn flush(&self) -> Result<(), ExecutorError>

Schedule all jobs currently buffered in this scope.

ThreadScheduler::scope calls this before waiting, so most callers do not need to invoke it directly. It is exposed for two-lane fork/join shapes where one branch should enter the scheduler before the caller executes the second branch locally. The scope still waits for every flushed job before returning, so borrowed data cannot escape.

Auto Trait Implementations§

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize = 256, const SPIN_LIMIT: usize = 8192> !Freeze for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize = 256, const SPIN_LIMIT: usize = 8192> !RefUnwindSafe for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize = 256, const SPIN_LIMIT: usize = 8192> !Send for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize = 256, const SPIN_LIMIT: usize = 8192> !Sync for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize = 256, const SPIN_LIMIT: usize = 8192> !UnwindSafe for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize, const SPIN_LIMIT: usize> Unpin for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>
where &'scope ThreadScheduler<BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>: Unpin, PhantomData<C>: Unpin,

§

impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize, const SPIN_LIMIT: usize> UnsafeUnpin for SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>
where &'scope ThreadScheduler<BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>: UnsafeUnpin, PhantomData<C>: UnsafeUnpin,

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.