[][src]Struct tasque::TaskQueue

pub struct TaskQueue { /* fields omitted */ }

Task queue.

This queue spawns worker threads for executing registered tasks.

Examples

use tasque::TaskQueue;

let queue = TaskQueue::new();
queue.enqueue(|| println!("Hello"));
queue.enqueue(|| println!("World"));

Methods

impl TaskQueue[src]

pub fn new() -> Self[src]

Makes a new TaskQueue instance.

This is equivalent to TaskQueueBuilder::new().finish().

pub fn enqueue<F>(&self, task: F) where
    F: FnOnce() + Send + 'static, 
[src]

Enqueues a task.

The task will be executed by a worker thread.

If the thread panics while executing the task, it will be automatically restarted. Note that the task will not be retried in such case.

pub fn set_worker_count(&self, count: usize)[src]

Updates the number of worker threads of this queue.

pub fn worker_count(&self) -> usize[src]

Returns the number of worker threads of this queue.

pub fn len(&self) -> usize[src]

Returns the number of tasks (enqueued but not yet dequeued) in this queue.

Trait Implementations

impl Default for TaskQueue[src]

impl Clone for TaskQueue[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for TaskQueue[src]

Auto Trait Implementations

Blanket Implementations

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.

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

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

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