Struct td_rthreadpool::ThreadPool
source · pub struct ThreadPool { /* private fields */ }
Implementations§
source§impl ThreadPool
impl ThreadPool
sourcepub fn new(n: usize) -> ThreadPool
pub fn new(n: usize) -> ThreadPool
Construct a threadpool with the given number of threads.
Minimum value is 1
.
pub fn new_with_name(n: usize, name: String) -> ThreadPool
sourcepub fn thread_count(&self) -> usize
pub fn thread_count(&self) -> usize
Returns the number of threads inside this pool.
sourcepub fn execute<F>(&self, job: F)where
F: FnOnce() + Send + 'static,
pub fn execute<F>(&self, job: F)where
F: FnOnce() + Send + 'static,
Executes the function job
on a thread in the pool.
pub fn join_all(&self)
sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of currently active threads.
sourcepub fn set_threads(&mut self, threads: usize) -> i32
pub fn set_threads(&mut self, threads: usize) -> i32
Sets the number of threads to use as threads
.
Can be used to change the threadpool size during runtime