Struct thread_pool::ThreadPool [] [src]

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

Execute tasks on one of possibly several pooled threads.

For more details, see the library level documentation.

Methods

impl<T: Task> ThreadPool<T>
[src]

Create a thread pool that reuses a fixed number of threads operating off a shared unbounded queue.

At any point, at most size threads will be active processing tasks. If additional tasks are submitted when all threads are active, they will wait in the queue until a thread is available. If any thread terminates due to a failure during execution prior to the thread pool shutting down, a new one will take its place if needed to execute subsequent tasks. The threads in the pool will exist until the thread pool is explicitly shutdown.

Create a thread pool with a single worker thread operating off an unbounded queue.

Note, however, that if this single thread termintaes due to a failure during execution prior to the thread pool shutting down, a new one will take its place if needed to execute subsequent tasks. Tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time.

Start a core thread, causing it to idly wait for work.

This overrides the default policy of starting core threads only when new tasks are executed. This function will return false if all core threads have already been started.

Start all core threads, causing them to idly wait for work.

This overrides the default policy of starting core threads only when new tasks are executed.

Initiate an orderly shutdown.

Any previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if the thread pool has already been shut down.

This function will not wait for previously submitted tasks to complete execution. Use await_termination to do that.

Shutdown the thread pool as fast as possible.

Worker threads will no longer receive tasks off of the work queue. This function will drain any remaining tasks before returning.

There are no guarantees beyond best-effort attempts to actually shutdown in a timely fashion. Threads will finish processing tasks that are currently running.

Returns true if the thread pool is in the process of terminating but has not yet terminated.

Returns true if the thread pool is currently terminated.

Blocks the current thread until the thread pool has terminated

Returns the current number of running threads

Returns the current number of pending tasks

Trait Implementations

impl<T> Clone for ThreadPool<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T> Debug for ThreadPool<T>
[src]

Formats the value using the given formatter.