This commit is contained in:
Shautvast 2026-02-09 20:24:19 +01:00
parent bbf889e72e
commit e4211e27bf

View file

@ -6,23 +6,25 @@ use std::{sync, thread};
static GET: &'static [u8] = b"GET / HTTP/1.1\r\n";
pub struct ThreadPool {
workers: Vec<Worker>,
sender: mpsc::Sender<Job>,
}
struct Worker {
id: usize,
thread: thread::JoinHandle<()>,
}
impl Worker {
fn new(id: usize) -> Worker {
let thread = thread::spawn(|| {});
fn new(id: usize, receiver: mpsc::Receiver<Job>) -> Worker {
let thread = thread::spawn(|| {
receiver;
});
Worker { id, thread }
}
}
pub struct ThreadPool {
workers: Vec<Worker>,
sender: mpsc::Sender<Job>,
}
impl ThreadPool {
/// Create a new ThreadPool
///
@ -34,7 +36,7 @@ impl ThreadPool {
let mut workers = Vec::with_capacity(size);
let (sender, receiver) = mpsc::channel();
for id in 0..size {
workers.push(Worker::new(id))
workers.push(Worker::new(id, receiver))
}
Self { workers, sender }
}