pub(super) struct Idle {
state: AtomicUsize,
num_workers: usize,
}
Fields§
§state: AtomicUsize
Tracks both the number of searching workers and the number of unparked workers.
Used as a fast-path to avoid acquiring the lock when needed.
num_workers: usize
Total number of workers.
Implementations§
source§impl Idle
impl Idle
pub(super) fn new(num_workers: usize) -> (Idle, Synced)
sourcepub(super) fn worker_to_notify(&self, shared: &Shared) -> Option<usize>
pub(super) fn worker_to_notify(&self, shared: &Shared) -> Option<usize>
If there are no workers actively searching, returns the index of a worker currently sleeping.
sourcepub(super) fn transition_worker_to_parked(
&self,
shared: &Shared,
worker: usize,
is_searching: bool,
) -> bool
pub(super) fn transition_worker_to_parked( &self, shared: &Shared, worker: usize, is_searching: bool, ) -> bool
Returns true
if the worker needs to do a final check for submitted
work.
pub(super) fn transition_worker_to_searching(&self) -> bool
sourcepub(super) fn transition_worker_from_searching(&self) -> bool
pub(super) fn transition_worker_from_searching(&self) -> bool
A lightweight transition from searching -> running.
Returns true
if this is the final searching worker. The caller
must notify a new worker.
sourcepub(super) fn unpark_worker_by_id(
&self,
shared: &Shared,
worker_id: usize,
) -> bool
pub(super) fn unpark_worker_by_id( &self, shared: &Shared, worker_id: usize, ) -> bool
Unpark a specific worker. This happens if tasks are submitted from within the worker’s park routine.
Returns true
if the worker was parked before calling the method.
sourcepub(super) fn is_parked(&self, shared: &Shared, worker_id: usize) -> bool
pub(super) fn is_parked(&self, shared: &Shared, worker_id: usize) -> bool
Returns true
if worker_id
is contained in the sleep set.
fn notify_should_wakeup(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Idle
impl RefUnwindSafe for Idle
impl Send for Idle
impl Sync for Idle
impl Unpin for Idle
impl UnwindSafe for Idle
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
Mutably borrows from an owned value. Read more