pub struct Pool { /* private fields */ }
Expand description

A thread-pool providing scoped and unscoped threads.

The primary ways of interacting with the Pool are the spawn and scoped convenience methods or through the Scope type directly.

Implementations§

Create a new Pool with size threads.

If size is zero, no threads will be spawned. Threads can be added later via expand.

NOTE: Since Pool can be freely cloned, it does not represent a unique handle to the thread pool. As a consequence, the thread pool is not automatically shut down; you must explicitly call Pool::shutdown to shut down the pool.

Create a new Pool with size threads and given thread config.

If size is zero, no threads will be spawned. Threads can be added later via expand.

NOTE: Since Pool can be freely cloned, it does not represent a unique handle to the thread pool. As a consequence, the thread pool is not automatically shut down; you must explicitly call Pool::shutdown to shut down the pool.

Create an empty Pool, with no threads.

Note that no jobs will run until expand is called and worker threads are added.

How many worker threads are currently active.

Spawn a 'static' job to be run on this pool.

We do not wait on the job to complete.

Panics in the job will propogate to the calling thread.

Create a Scope for scheduling a group of jobs in 'scope'.

scoped will return only when the scheduler function and all jobs queued on the given Scope have been run.

Panics in any of the jobs or in the scheduler function itself will propogate to the calling thread.

Shutdown the Pool.

WARNING: Extreme care should be taken to not call shutdown concurrently with any scoped calls, or deadlock can occur.

All threads will be shut down eventually, but only threads started before the call to shutdown are guaranteed to be shut down before the call to shutdown returns.

Expand the Pool by spawning an additional thread.

Can accelerate the completion of running jobs.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.