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,
impl<'scope, C, const BLOCKING_QUEUE_CAPACITY: usize, const SPIN_LIMIT: usize> SchedulerScope<'scope, C, BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>where
C: WorkClass,
Sourcepub fn spawn<F>(&self, task: F) -> Result<(), ExecutorError>
pub fn spawn<F>(&self, task: F) -> Result<(), ExecutorError>
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.
Sourcepub fn flush(&self) -> Result<(), ExecutorError>
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.