Skip to main content

get_thread_pool

Function get_thread_pool 

Source
pub fn get_thread_pool(num_threads: usize) -> Result<Arc<ThreadPool>>
Expand description

Get or create a thread pool with the specified number of threads

Thread pools are cached globally to avoid creation overhead on repeated calls. Creating a thread pool can take 10-40ms depending on the thread count, so caching provides significant performance benefits.

§Arguments

  • num_threads - Number of threads for the pool (must be > 0)

§Returns

A reference-counted handle to the thread pool