Debian Codegraph @

README.md

raw symbols SCIP
1 # Threadfin
2
3 A thread pool for running multiple tasks on a configurable group of threads.
4
5 [![Crates.io](https://img.shields.io/crates/v/threadfin.svg)](https://crates.io/crates/threadfin)
6 [![Documentation](https://docs.rs/threadfin/badge.svg)](https://docs.rs/threadfin)
7 [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
8 [![Minimum supported Rust version](https://img.shields.io/badge/rustc-1.51+-yellow.svg)](#minimum-supported-rust-version)
9 [![Build](https://github.com/sagebind/threadfin/workflows/ci/badge.svg)](https://github.com/sagebind/threadfin/actions)
10
11 Extra features:
12
13 - Dynamic pool size based on load
14 - Support for async tasks
15 - Tasks return a handle which can be joined or awaited for the return value
16 - Optional common process-wide thread pool
17
18 ## Async support
19
20 Threadfin supports asynchronous usage via futures, and allows you to mix and match both synchronous and asynchronous tasks within a single thread pool.
21
22 ## Examples
23
24 ```rust
25 // Create a new pool.
26 let pool = threadfin::builder().size(8).build();
27
28 // Schedule some work.
29 let compute_task = pool.execute(|| {
30 // Some expensive computation
31 2 + 2
32 });
33
34 // Do something in the meantime.
35 println!("Waiting for result...");
36
37 // Wait for the task to complete and get the result.
38 let sum = compute_task.join();
39 println!("Sum: 2 + 2 = {}", sum);
40 ```
41
42 ## Installation
43
44 Install via Cargo by adding to your Cargo.toml file:
45
46 ```toml
47 [dependencies]
48 threadfin = "0.1"
49 ```
50
51 ### Minimum supported Rust version
52
53 The minimum supported Rust version (or MSRV) for Threadfin is stable Rust 1.46 or greater, meaning we only guarantee that Threadfin will compile if you use a rustc version of at least 1.46. It might compile with older versions but that could change at any time.
54
55 This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes.
56
57 ## Other libraries
58
59 - [threadpool](https://github.com/rust-threadpool/rust-threadpool)
60 - [scoped_threadpool](https://github.com/kimundi/scoped-threadpool-rs)
61 - [rusty_pool](https://github.com/robinfriedli/rusty_pool)
62 - [rayon](https://github.com/rayon-rs/rayon)
63
64 ## Sponsors
65
66 Special thanks to sponsors of my open-source work!
67
68 <!-- sponsors --><a href="https://github.com/da-moon"><img src="https://github.com/da-moon.png" width="60px" alt="da-moon" /></a><!-- sponsors -->
69
70 ## License
71
72 Licensed under the MIT license. See the [LICENSE](LICENSE) file for details.