Struct task_queue::TaskQueue [] [src]

pub struct TaskQueue { /* fields omitted */ }

Methods

impl TaskQueue
[src]

Create new task queue with 10 threads.

Create new task queue with selected threads count.

Schedule task in queue

Example

extern crate task_queue;

let mut queue = task_queue::TaskQueue::new();

for _ in 0..10 {
   queue.enqueue(move || {
       println!("Hi from pool")
   }).unwrap();
}

Panics

If spawn policy returned illegal number of threads.

Stops tasks queue work. All task in queue will be completed by threads. Method not block current thread work, but returns threads joinHandles.

Examples

extern crate task_queue;

let mut queue = task_queue::TaskQueue::new();

for _ in 0..10 {
   queue.enqueue(move || {
       println!("Hi from pool")
   }).unwrap();
}
let handles = queue.stop();
for h in handles {
    h.join().unwrap();
}

Stops tasks queue work. All task in queue will be completed by threads. Method block current thread work.

Examples

extern crate task_queue;

let mut queue = task_queue::TaskQueue::new();

for _ in 0..10 {
   queue.enqueue(move || {
       println!("Hi from pool")
   }).unwrap();
}
queue.stop_wait();

Stops tasks queue work immediately and return are not completed tasks.

Examples

extern crate task_queue;

let mut queue = task_queue::TaskQueue::new();

for _ in 0..10 {
   queue.enqueue(move || {
       println!("Hi from pool")
   }).unwrap();
}
let not_completed = queue.stop_immediately();
for t in &not_completed {
    t.run();
}

Sets a policy for controlling the amount of threads

Returns current threads count

Return max threads count

Return min threads count

Gets tasks count in queue

Trait Implementations

impl Drop for TaskQueue
[src]

All task in queue will be completed by threads.