Struct rayon_core::sleep::Sleep

source ·
pub(crate) struct Sleep {
    worker_sleep_states: Vec<CachePadded<WorkerSleepState>>,
    counters: AtomicCounters,
}
Expand description

The Sleep struct is embedded into each registry. It governs the waking and sleeping of workers. It has callbacks that are invoked periodically at significant events, such as when workers are looping and looking for work, when latches are set, or when jobs are published, and it either blocks threads or wakes them in response to these events. See the [README.md] in this module for more details.

[README.md] README.md

Fields§

§worker_sleep_states: Vec<CachePadded<WorkerSleepState>>

One “sleep state” per worker. Used to track if a worker is sleeping and to have them block.

§counters: AtomicCounters

Implementations§

source§

impl Sleep

source

pub(crate) fn new(n_threads: usize) -> Sleep

source

pub(crate) fn start_looking(&self, worker_index: usize) -> IdleState

source

pub(crate) fn work_found(&self)

source

pub(crate) fn no_work_found( &self, idle_state: &mut IdleState, latch: &CoreLatch, has_injected_jobs: impl FnOnce() -> bool, )

source

fn announce_sleepy(&self) -> JobsEventCounter

source

fn sleep( &self, idle_state: &mut IdleState, latch: &CoreLatch, has_injected_jobs: impl FnOnce() -> bool, )

source

pub(crate) fn notify_worker_latch_is_set(&self, target_worker_index: usize)

Notify the given thread that it should wake up (if it is sleeping). When this method is invoked, we typically know the thread is asleep, though in rare cases it could have been awoken by (e.g.) new work having been posted.

source

pub(crate) fn new_injected_jobs(&self, num_jobs: u32, queue_was_empty: bool)

Signals that num_jobs new jobs were injected into the thread pool from outside. This function will ensure that there are threads available to process them, waking threads from sleep if necessary.

§Parameters
  • num_jobs – lower bound on number of jobs available for stealing. We’ll try to get at least one thread per job.
source

pub(crate) fn new_internal_jobs(&self, num_jobs: u32, queue_was_empty: bool)

Signals that num_jobs new jobs were pushed onto a thread’s local deque. This function will try to ensure that there are threads available to process them, waking threads from sleep if necessary. However, this is not guaranteed: under certain race conditions, the function may fail to wake any new threads; in that case the existing thread should eventually pop the job.

§Parameters
  • num_jobs – lower bound on number of jobs available for stealing. We’ll try to get at least one thread per job.
source

fn new_jobs(&self, num_jobs: u32, queue_was_empty: bool)

Common helper for new_injected_jobs and new_internal_jobs.

source

fn wake_any_threads(&self, num_to_wake: u32)

source

fn wake_specific_thread(&self, index: usize) -> bool

Auto Trait Implementations§

§

impl !Freeze for Sleep

§

impl RefUnwindSafe for Sleep

§

impl Send for Sleep

§

impl Sync for Sleep

§

impl Unpin for Sleep

§

impl UnwindSafe for Sleep

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.