[go: up one dir, main page]

Struct worker::Worker [] [src]

pub struct Worker<T> { /* fields omitted */ }

The worker is a thread based working queue. After you initialized the worker with the callback you want you can add items to it. As soon as the item is ready to process the callback will be called to handle the logic.

Example

let mut w = Worker::<&'static str>::single(move |r| {
    println!("{:?}", r);
});

w.add("1");
w.add("2");

w.stop();

Methods

impl<T> Worker<T> where
    T: Send + 'static, 
[src]

Creates a single instance worker

Creates a multi instance worker (count defines the number of threads to be started)

Adds an item to the working queue

Stops the workers gracefully