TaskQueues

Trait TaskQueues 

Source
pub trait TaskQueues<W: Worker>:
    Sized
    + Send
    + Sync
    + 'static {
    type WorkerQueues: WorkerQueues<W>;

    // Required methods
    fn new(token: Token) -> Self;
    fn init_for_threads(
        &self,
        start_index: usize,
        end_index: usize,
        config: &Config,
    );
    fn update_for_threads(
        &self,
        start_index: usize,
        end_index: usize,
        config: &Config,
    );
    fn try_push_global(&self, task: Task<W>) -> Result<(), Task<W>>;
    fn worker_queues(&self, thread_index: usize) -> Self::WorkerQueues;
    fn close(&self, urgent: bool, token: Token);
    fn drain(self) -> Vec<Task<W>>;
}
Expand description

Trait that encapsulates the global and local task queues used by a Hive for managing tasks within and between worker threads.

This trait is sealed - it cannot be implemented outside of this crate.

Required Associated Types§

Source

type WorkerQueues: WorkerQueues<W>

Required Methods§

Source

fn new(token: Token) -> Self

Returns a new instance.

The private Token is used to prevent this method from being called externally.

Source

fn init_for_threads( &self, start_index: usize, end_index: usize, config: &Config, )

Initializes the local queues for the given range of worker thread indices.

Source

fn update_for_threads( &self, start_index: usize, end_index: usize, config: &Config, )

Updates the queue settings from config for the given range of worker threads.

Source

fn try_push_global(&self, task: Task<W>) -> Result<(), Task<W>>

Tries to add a task to the global queue.

Returns an error with the task if the queue is disconnected.

Source

fn worker_queues(&self, thread_index: usize) -> Self::WorkerQueues

Returns a WorkerQueues instance for the worker thread with the given index.

Source

fn close(&self, urgent: bool, token: Token)

Closes this GlobalQueue so no more tasks may be pushed.

If urgent is true, this also prevents queued tasks from being popped.

The private Token is used to prevent this method from being called externally.

Source

fn drain(self) -> Vec<Task<W>>

Consumes this TaskQueues and Drains all tasks from all global and local queues and returns them as a Vec.

This method panics if close has not been called.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<W: Worker> TaskQueues<W> for ChannelTaskQueues<W>

Source§

type WorkerQueues = ChannelWorkerQueues<W>

Source§

impl<W: Worker> TaskQueues<W> for WorkstealingTaskQueues<W>

Source§

type WorkerQueues = WorkstealingWorkerQueues<W>