pub struct ThreadPool {
pub workers: Vec<Worker>,
pub sender: Sender<Box<dyn FnOnce() + Send + 'static>>,
}Expand description
§ThreadPool
ThreadPool - Struct representing a thread pool.
§Example
Create an instance of ThreadPool:
let pool = ThreadPool::new(10);This will create 10 workers (threads).
Than you will able to use execute method, which will start task execution.
And since this method gets a closure or a regular function in the parameter:
§#1
pool.execute(|| {
println!("Yoo!");
});
§#2
pool.execute(some_function);Fields§
§workers: Vec<Worker>§sender: Sender<Box<dyn FnOnce() + Send + 'static>>Implementations§
Auto Trait Implementations§
impl Freeze for ThreadPool
impl !RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl !UnwindSafe for ThreadPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more