#thread #pool #numbers #running #task #worker-thread #single

thread-pool

A thread pool for running a number of jobs on shared worker threads

2 releases

Uses old Rust 2015

0.1.1 Mar 14, 2017
0.1.0 Jan 4, 2017

#44 in #worker-thread

Download history 63/week @ 2024-04-01 21/week @ 2024-04-08 28/week @ 2024-04-15 39/week @ 2024-04-22 39/week @ 2024-04-29 17/week @ 2024-05-06 28/week @ 2024-05-13 17/week @ 2024-05-20 42/week @ 2024-05-27 27/week @ 2024-06-03 29/week @ 2024-06-10 22/week @ 2024-06-17 25/week @ 2024-06-24 37/week @ 2024-07-01 12/week @ 2024-07-08 117/week @ 2024-07-15

195 downloads per month

MIT/Apache

34KB
581 lines

Thread pool for Rust

A library for executing tasks on reusable threads.

Build Status Crates.io

Documentation

Usage

First add this to your Cargo.toml

[dependencies]
thread-pool = "0.1"

Next, add this to your crate:

extern crate thread_pool;

use thread_pool::ThreadPool;

License

thread-pool is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.

The library is also inspired from parts of JSR-166 which is released to the public domain.


lib.rs:

Execute tasks on one of possibly several pooled threads.

A thread pool contains a set of previously spawned threads enabling running tasks in parallel without having to spawn up a new thread for each task. The thread pool supports a variety of different configuration options useful for tweaking its exact behavior.

Thread pools address two different porblems: they usually provide improved performance when executing large numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and managing the resources, including threads, consumed when executing a collection of tasks.

To be useful across a wide range of contexts, ThreadPool provides a number of adjustable parameters and extensibility hooks. However, programmers are urged to use the more convenient builder methods, fixed_size, and single_thread (single background thread), that preconfigure settings for the most common usage scenarios. Otherwise, use the following guide when manually configuring and tuning a ThreadPool.

Dependencies

~110KB