Struct forkjoin::ForkPool
[−]
[src]
pub struct ForkPool<Arg: 'static + Send, Ret: 'static + Send + Sync> { // some fields omitted }
Main struct of the ForkJoin library. Represents a pool of threads implementing a work stealing algorithm.
Methods
impl<Arg: 'static + Send, Ret: 'static + Send + Sync> ForkPool<Arg, Ret>
[src]
fn new() -> ForkPool<Arg, Ret>
Create a new ForkPool
using num_cpus to determine pool size
On a X-core cpu with hyper-threading it creates 2X threads (4 core intel with HT results in 8 threads). This is not optimal. It makes the computer very slow and don't yield very much speedup compared to X threads. Not sure how to best fix this. Not very high priority.
fn with_threads(nthreads: usize) -> ForkPool<Arg, Ret>
Create a new ForkPool
with nthreads
WorkerThread
s at its disposal.
fn schedule(&self, fun: TaskFun<Arg, Ret>, arg: Arg) -> Receiver<Ret>
Schedule a new computation on this ForkPool
. Returns instantly.
Return value(s) can be read from the returned Receiver<Ret>
.
AlgoStyle::Summa
will only return one message on this channel.
AlgoStyle::Search
algorithm might return arbitrary number of messages.
Algorithm termination is detected by the Receiver<Ret>
returning an Err