pub struct Stealer<'worker, S> { /* private fields */ }
Expand description
Implementations§
source§impl<'worker, S: Schedule> Stealer<'worker, S>
impl<'worker, S: Schedule> Stealer<'worker, S>
sourcepub fn initial_task_count(&self) -> usize
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.
sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
Returns the number of tasks currently in the targeted queue.
sourcepub fn spawn_one(&self, scheduler: &S) -> bool
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.
sourcepub fn spawn_n(&self, scheduler: &S, max: usize) -> usize
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
.
sourcepub fn spawn_half(&self, scheduler: &S) -> usize
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.