From 7438669ef18499cdd59b49ac484e864a4bee37c8 Mon Sep 17 00:00:00 2001 From: Mahmut Bulut Date: Wed, 30 Oct 2019 22:06:22 +0100 Subject: [PATCH] Run queue docs --- bastion-executor/examples/spawn_async.rs | 2 +- bastion-executor/src/run_queue.rs | 92 ------------------------ 2 files changed, 1 insertion(+), 93 deletions(-) diff --git a/bastion-executor/examples/spawn_async.rs b/bastion-executor/examples/spawn_async.rs index 4cabf40b..84d5ec11 100644 --- a/bastion-executor/examples/spawn_async.rs +++ b/bastion-executor/examples/spawn_async.rs @@ -17,7 +17,7 @@ fn main() { run( async { - handle.await + handle.await; }, stack.clone() ); diff --git a/bastion-executor/src/run_queue.rs b/bastion-executor/src/run_queue.rs index 15b54983..df52e296 100644 --- a/bastion-executor/src/run_queue.rs +++ b/bastion-executor/src/run_queue.rs @@ -38,42 +38,6 @@ //! In contrast to push and pop operations, stealing can spuriously fail with [`Steal::Retry`], in //! which case the steal operation needs to be retried. //! -//! # Examples -//! -//! Suppose a thread in a work-stealing scheduler is idle and looking for the next task to run. To -//! find an available task, it might do the following: -//! -//! 1. Try popping one task from the local worker queue. -//! 2. Try stealing a batch of tasks from the global injector queue. -//! 3. Try stealing one task from another thread using the stealer list. -//! -//! An implementation of this work-stealing strategy: -//! -//! ``` -//! use crossbeam_deque::{Injector, Steal, Stealer, Worker}; -//! use std::iter; -//! -//! fn find_task( -//! local: &Worker, -//! global: &Injector, -//! stealers: &[Stealer], -//! ) -> Option { -//! // Pop a task from the local queue, if not empty. -//! local.pop().or_else(|| { -//! // Otherwise, we need to look for a task elsewhere. -//! iter::repeat_with(|| { -//! // Try stealing a batch of tasks from the global queue. -//! global.steal_batch_and_pop(local) -//! // Or try stealing a task from one of the other threads. -//! .or_else(|| stealers.iter().map(|s| s.steal()).collect()) -//! }) -//! // Loop while no task was stolen and any steal operation needs to be retried. -//! .find(|s| !s.is_retry()) -//! // Extract the stolen task, if there is one. -//! .and_then(|s| s.success()) -//! }) -//! } -//! ``` //! //! [`Worker`]: struct.Worker.html //! [`Stealer`]: struct.Stealer.html @@ -239,42 +203,6 @@ enum Flavor { /// /// This is a FIFO or LIFO queue that is owned by a single thread, but other threads may steal /// tasks from it. Task schedulers typically create a single worker queue per thread. -/// -/// # Examples -/// -/// A FIFO worker: -/// -/// ``` -/// use crossbeam_deque::{Steal, Worker}; -/// -/// let w = Worker::new_fifo(); -/// let s = w.stealer(); -/// -/// w.push(1); -/// w.push(2); -/// w.push(3); -/// -/// assert_eq!(s.steal(), Steal::Success(1)); -/// assert_eq!(w.pop(), Some(2)); -/// assert_eq!(w.pop(), Some(3)); -/// ``` -/// -/// A LIFO worker: -/// -/// ``` -/// use crossbeam_deque::{Steal, Worker}; -/// -/// let w = Worker::new_lifo(); -/// let s = w.stealer(); -/// -/// w.push(1); -/// w.push(2); -/// w.push(3); -/// -/// assert_eq!(s.steal(), Steal::Success(1)); -/// assert_eq!(w.pop(), Some(3)); -/// assert_eq!(w.pop(), Some(2)); -/// ``` pub struct Worker { /// A reference to the inner representation of the queue. inner: Arc>>, @@ -293,16 +221,6 @@ unsafe impl Send for Worker {} impl Worker { /// Creates a FIFO worker queue. - /// - /// Tasks are pushed and popped from opposite ends. - /// - /// # Examples - /// - /// ``` - /// use crossbeam_deque::Worker; - /// - /// let w = Worker::::new_fifo(); - /// ``` pub fn new_fifo() -> Worker { let buffer = Buffer::alloc(MIN_CAP); @@ -321,16 +239,6 @@ impl Worker { } /// Creates a LIFO worker queue. - /// - /// Tasks are pushed and popped from the same end. - /// - /// # Examples - /// - /// ``` - /// use crossbeam_deque::Worker; - /// - /// let w = Worker::::new_lifo(); - /// ``` pub fn new_lifo() -> Worker { let buffer = Buffer::alloc(MIN_CAP);