Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! A thread pool for running multiple tasks on a configurable group of threads.
2 //!
3 //! Extra features:
4 //!
5 //! - Dynamic pool size based on load
6 //! - Support for async tasks
7 //! - Tasks return a handle which can be joined or awaited for the return value
8 //! - Optional common process-wide thread pool
9 //!
10 //! ## Async support
11 //!
12 //! Threadfin supports asynchronous usage via futures, and allows you to mix and
13 //! match both synchronous and asynchronous tasks within a single thread pool.
14 //!
15 //! ## Examples
16 //!
17 //! ```
18 //! // Create a new pool.
19 //! let pool = threadfin::builder().size(8).build();
20 //!
21 //! // Schedule some work.
22 //! let compute_task = pool.execute(|| {
23 //! // Some expensive computation
24 //! 2 + 2
25 //! });
26 //!
27 //! // Do something in the meantime.
28 //! println!("Waiting for result...");
29 //!
30 //! // Wait for the task to complete and get the result.
31 //! let sum = compute_task.join();
32 //! println!("Sum: 2 + 2 = {}", sum);
33 //! ```
34
35 mod commonrust-analyzer cargo threadfin 0.1.2 common/;
36 mod errorrust-analyzer cargo threadfin 0.1.2 error/;
37 mod poolrust-analyzer cargo threadfin 0.1.2 pool/;
38 mod taskrust-analyzer cargo threadfin 0.1.2 task/;
39 mod wakersrust-analyzer cargo threadfin 0.1.2 wakers/;
40 mod workerrust-analyzer cargo threadfin 0.1.2 worker/;
41
42 pub use craterust-analyzer cargo threadfin 0.1.2 crate/::{
43 commonrust-analyzer cargo threadfin 0.1.2 common/::*,
44 errorrust-analyzer cargo threadfin 0.1.2 error/::*,
45 poolrust-analyzer cargo threadfin 0.1.2 pool/::{Builderrust-analyzer cargo threadfin 0.1.2 pool/Builder#, PerCorerust-analyzer cargo threadfin 0.1.2 pool/PerCore#, SizeConstraintrust-analyzer cargo threadfin 0.1.2 pool/SizeConstraint#, ThreadPoolrust-analyzer cargo threadfin 0.1.2 pool/ThreadPool#},
46 taskrust-analyzer cargo threadfin 0.1.2 task/::Taskrust-analyzer cargo threadfin 0.1.2 task/Task#,
47 };
48
49 /// Get a builder for creating a customized thread pool.
50 ///
51 /// A shorthand for [`ThreadPool::builder`].
52 #[inline]
53 pub fn builderrust-analyzer cargo threadfin 0.1.2 builder().() -> Builderrust-analyzer cargo threadfin 0.1.2 pool/Builder# {
54 ThreadPoolrust-analyzer cargo threadfin 0.1.2 pool/ThreadPool#::builderrust-analyzer cargo threadfin 0.1.2 pool/impl#[ThreadPool]builder().()
55 }