Struct jobsteal::Pool [] [src]

pub struct Pool {
    // some fields omitted
}

The work pool manages worker threads in a work-stealing fork-join thread pool.

You can submit jobs to the pool directly using Pool::submit. This has similar semantics to the standard library thread::spawn, in that the work provided must fully own its data.

Pool also provides a facility for spawning scoped jobs via the "scope" function.

Methods

impl Pool
[src]

fn synchronize(&mut self)

Finish all current jobs which are queued, and synchronize the workers until it's time to start again.

If any of the threads have panicked, that panic will be propagated to this thread. Until the next job is submitted, workers will block, allowing other threads to have higher priority.

fn scope<'pool, 'new, F, R>(&'pool mut self, f: F) -> R where F: 'new + FnOnce(&Spawner<'pool, 'new>) -> R, R: 'new

Create a new spawning scope for submitting jobs.

This is shorthand for my_pool.spawner().scope(|scope| ...).

Any jobs submitted in this scope will be completed by the end of this function call. See Spawner::scope for a more detailed description.

fn recurse<'a, F>(&'a mut self, f: F) where F: 'static + Send + FnOnce(&Spawner<'a, 'static>)

Execute a job which strictly owns its contents and is to be given access to the thread pool.

The execution of this function may be deferred beyond this function call, to as far as either the next call to synchronize or the pool's destructor.

This is shorthand for my_pool.spawner().recurse(my_job);

Safety

In the general case, it is safe to submit jobs which only strictly outlive the pool. However, there is always the chance that the pool could be leaked, violating the invariant that the job is completed while its data is still alive.

fn submit<'a, F>(&'a mut self, f: F) where F: 'static + Send + FnOnce()

Execute a job which strictly owns its contents.

The execution of this function may be deferred beyond this function call, to as far as either the next call to synchronize or the pool's destructor.

This is shorthand for my_pool.spawner().submit(my_job);

Safety

In the general case, it is safe to submit jobs which only strictly outlive the pool. However, there is always the chance that the pool could be leaked, violating the invariant that the job is completed while its data is still alive.

fn spin_up(&mut self)

Spin up all the workers, in case they were in a paused state.

fn spawner<'a>(&'a mut self) -> Spawner<'a, 'static>

Get the pool's spawner.

This will initally only accept jobs which outive 'static, but the scope can be focused further. See the Spawner documentation for more information.

Trait Implementations

impl Drop for Pool
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more