Skip to main content

## WorkerThread

# Struct WorkerThread

Source

    pub(crate) struct WorkerThread {
        worker: Worker<JobRef>,
        stealer: Stealer<JobRef>,
        fifo: JobFifo,
        pub(crate) index: usize,
        rng: XorShift64Star,
        pub(crate) registry: Arc<Registry>,
    }

## Fields§

§`worker: Worker<JobRef>`

the “worker” half of our local deque

§`stealer: Stealer<JobRef>`

the “stealer” half of the worker’s broadcast deque

§`fifo: JobFifo`

local queue used for `spawn_fifo` indirection

§`index: usize`§`rng: XorShift64Star`

A weak random number generator.

§`registry: Arc<Registry>`

## Implementations§

Source§

### impl WorkerThread

Source

#### pub(crate) fn current() -> *const WorkerThread

Gets the `WorkerThread` index for the current thread; returns NULL if this is not a worker thread. This pointer is valid anywhere on the current thread.

Source

#### unsafe fn set_current(thread: *const WorkerThread)

Sets `self` as the worker thread index for the current thread. This is done during worker thread startup.

Source

#### pub(crate) fn registry(&self) -> &Arc<Registry>

Returns the registry that owns this worker thread.

Source

#### pub(crate) fn index(&self) -> usize

Our index amongst the worker threads (ranges from `0..self.num_threads()`).

Source

#### pub(crate) unsafe fn push(&self, job: JobRef)

Source

#### pub(crate) unsafe fn push_fifo(&self, job: JobRef)

Source

#### pub(crate) fn local_deque_is_empty(&self) -> bool

Source

#### pub(crate) fn take_local_job(&self) -> Option<JobRef>

Attempts to obtain a “local” job – typically this means popping from the top of the stack, though if we are configured for breadth-first execution, it would mean dequeuing from the bottom.

Source

#### pub(crate) fn has_injected_job(&self) -> bool

Source

#### pub(crate) unsafe fn wait_until<L: AsCoreLatch + ?Sized>(&self, latch: &L)

Wait until the latch is set. Try to keep busy by popping and stealing tasks as necessary.

Source

#### pub(crate) unsafe fn wait_for_jobs<L: AsCoreLatch + ?Sized, const BROADCAST_JOBS: bool>( &self, latch: &L, all_jobs_started: impl FnMut() -> bool, is_job: impl FnMut(&JobRef) -> bool, execute_job: impl FnMut(JobRef), )

Wait until the latch is set. Executes local jobs if `is_job` is true for them and `all_jobs_started` still returns false.

Source

#### pub(crate) unsafe fn wait_or_steal_until<L: AsCoreLatch + ?Sized>( &self, latch: &L, steal: bool, )

Source

#### unsafe fn wait_or_steal_until_cold(&self, latch: &CoreLatch)

Source

#### unsafe fn wait_until_cold(&self, latch: &CoreLatch)

Source

#### unsafe fn wait_until_out_of_work(&self)

Source

#### fn find_work(&self) -> Option<JobRef>

Source

#### pub(crate) fn yield_now(&self) -> Yield

Source

#### pub(crate) fn yield_local(&self) -> Yield

Source

#### pub(crate) unsafe fn execute(&self, job: JobRef)

Source

#### fn steal(&self) -> Option<JobRef>

Try to steal a single job and return it.

This should only be done as a last resort, when there is no local work to do.

## Trait Implementations§

Source§

### impl Drop for WorkerThread

Source§

#### fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

#### fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (`pin_ergonomics`)
Execute the destructor for this type, but different to `Drop::drop`, it requires `self` to be pinned. Read more
Source§

### impl From<ThreadBuilder> for WorkerThread

Source§

#### fn from(thread: ThreadBuilder) -> Self

Converts to this type from the input type.

## Auto Trait Implementations§

§

### impl !Freeze for WorkerThread

§

### impl !RefUnwindSafe for WorkerThread

§

### impl !Sync for WorkerThread

§

### impl !UnwindSafe for WorkerThread

§

### impl Send for WorkerThread

§

### impl Unpin for WorkerThread

§

### impl UnsafeUnpin for WorkerThread

## 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.
Source§

#### 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>,

Source§

#### 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>,

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.

## Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain `repr(...)` attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 384 bytes