Struct maitake::scheduler::Stealer

source ·
pub struct Stealer<'worker, S> { /* private fields */ }
Expand description

A handle for stealing tasks from a Scheduler’s run queue, or an Injector queue.

While this handle exists, no other worker can steal tasks from the queue.

Implementations§

source§

impl<'worker, S: Schedule> Stealer<'worker, S>

source

pub fn initial_task_count(&self) -> usize

Returns the number of tasks that were in the targeted queue when this Stealer was created.

This number is not guaranteed to be greater than the current number of tasks returned by task_count, as new tasks may be enqueued while stealing.

source

pub fn task_count(&self) -> usize

Returns the number of tasks currently in the targeted queue.

source

pub fn spawn_one(&self, scheduler: &S) -> bool

Steal one task from the targeted queue and spawn it on the provided scheduler.

Returns
  • true if a task was successfully stolen.
  • false if the targeted queue is empty.
source

pub fn spawn_n(&self, scheduler: &S, max: usize) -> usize

Steal up to max tasks from the targeted queue and spawn them on the provided scheduler.

Returns

The number of tasks stolen. This may be less than max if the targeted queue contained fewer tasks than max.

source

pub fn spawn_half(&self, scheduler: &S) -> usize

Steal half of the tasks currently in the targeted queue and spawn them on the provided scheduler.

This is a convenience method that is equivalent to the following:

stealer.spawn_n(&scheduler, stealer.initial_task_count() / 2);
Returns

The number of tasks stolen.

Trait Implementations§

source§

impl<S> Debug for Stealer<'_, S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'worker, S> !RefUnwindSafe for Stealer<'worker, S>

§

impl<'worker, S> Send for Stealer<'worker, S>

§

impl<'worker, S> Sync for Stealer<'worker, S>

§

impl<'worker, S> Unpin for Stealer<'worker, S>

§

impl<'worker, S> !UnwindSafe for Stealer<'worker, S>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more