pub struct Context<TTask> {
pub Identifier: usize,
pub Local: (Worker<TTask>, Worker<TTask>, Worker<TTask>),
pub Share: Arc<Share<TTask>>,
}Expand description
Contains all necessary components for a single worker thread to operate.
This includes the thread-local Worker deques, which are not safe to share,
making this Context object the sole owner of a worker’s private queues.
Fields§
§Identifier: usizeA unique identifier for the worker, used to avoid self-stealing.
Local: (Worker<TTask>, Worker<TTask>, Worker<TTask>)Thread-local work queues for each priority level.
A reference to the shared components of the entire queue system.
Implementations§
Source§impl<TTask> Context<TTask>
impl<TTask> Context<TTask>
Sourcepub fn Next(&self) -> Option<TTask>
pub fn Next(&self) -> Option<TTask>
Finds the next available task for the worker to execute.
This method implements the complete work-finding logic:
- Check local deques (from high to low priority).
- If local deques are empty, attempt to steal from the system (from high to low priority).
Sourcepub fn Steal<'a>(
&self,
Injector: &'a Injector<TTask>,
Stealers: &'a [Stealer<TTask>],
Local: &'a Worker<TTask>,
) -> Option<TTask>
pub fn Steal<'a>( &self, Injector: &'a Injector<TTask>, Stealers: &'a [Stealer<TTask>], Local: &'a Worker<TTask>, ) -> Option<TTask>
Attempts to steal a task from a specific priority set.
It first tries to steal a batch from the global injector queue for that priority. If that fails, it attempts to steal from a randomly chosen peer worker to ensure fair distribution and avoid contention hotspots.
Auto Trait Implementations§
impl<TTask> !Freeze for Context<TTask>
impl<TTask> !RefUnwindSafe for Context<TTask>
impl<TTask> Send for Context<TTask>where
TTask: Send,
impl<TTask> !Sync for Context<TTask>
impl<TTask> Unpin for Context<TTask>
impl<TTask> UnsafeUnpin for Context<TTask>
impl<TTask> UnwindSafe for Context<TTask>where
TTask: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more