Struct work_queue::Queue[][src]

pub struct Queue<T>(_);

A work queue.

This implements Clone and so multiple handles to the queue can be easily created and shared.

Implementations

impl<T> Queue<T>[src]

pub fn new(local_queues: usize, local_queue_size: u16) -> Self[src]

Create a new work queue.

local_queues is the number of LocalQueues yielded by Self::local_queues. Typically you will have a local queue for each thread on a thread pool.

local_queue_size is the number of items that can be stored in each local queue before it overflows into the global one. You should fine-tune this to your needs.

Panics

This will panic if the local queue size is not a power of two.

Examples

use work_queue::Queue;

let threads = 4;
let queue: Queue<i32> = Queue::new(threads, 512);

pub fn push(&self, item: T)[src]

Push an item to the global queue. When one of the local queues empties, they can pick this item up.

pub fn local_queues(&self) -> LocalQueues<'_, T>

Notable traits for LocalQueues<'_, T>

impl<T> Iterator for LocalQueues<'_, T> type Item = LocalQueue<T>;
[src]

Iterate over the local queues of this queue.

Panics

This will panic if called more than one time.

Trait Implementations

impl<T> Clone for Queue<T>[src]

impl<T: Debug> Debug for Queue<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Queue<T>

impl<T> Send for Queue<T> where
    T: Send

impl<T> Sync for Queue<T> where
    T: Send

impl<T> Unpin for Queue<T>

impl<T> !UnwindSafe for Queue<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.