maitake::scheduler

Struct 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> Freeze for Stealer<'worker, S>

§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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

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.