Enum Msg

Variants

Struct TaskPool

pub struct TaskPool <T>{
    channels: ~[Chan<Msg<T>>],
    mut next_index: uint,
}

Implementation for TaskPool<T>

Method new

fn new(n_tasks: uint, opt_sched_mode: Option<SchedMode>,
       init_fn_factory: ~fn() -> ~fn(uint) -> T) -> TaskPool<T>

Spawns a new task pool with n_tasks tasks. If the sched_mode is None, the tasks run on this scheduler; otherwise, they run on a new scheduler with the given mode. The provided init_fn_factory returns a function which, given the index of the task, should return local data to be kept around in that task.

Method execute

fn execute(f: ~fn(&T))

Executes the function f on a task in the pool. The function receives a reference to the local data returned by the init_fn.