This commit is contained in:
Shautvast 2026-02-09 20:09:57 +01:00
parent 5795b74d8e
commit 24f0ca7de1

View file

@ -6,7 +6,19 @@ use std::thread;
static GET: &'static [u8] = b"GET / HTTP/1.1\r\n";
pub struct ThreadPool {
threads: Vec<thread::JoinHandle<()>>,
workers: Vec<Worker>,
}
struct Worker{
id: usize,
thread: thread::JoinHandle<()>,
}
impl Worker {
fn new(id: usize) -> Worker {
let thread = thread::spawn(|| {});
Worker { id, thread }
}
}
impl ThreadPool {
@ -17,13 +29,13 @@ impl ThreadPool {
/// The `new` function panics if the size is zero
pub fn new(size: usize) -> Self {
assert!(size > 0);
let threads = Vec::with_capacity(size);
for _ in 0..size {
let mut workers = Vec::with_capacity(size);
for id in 0..size {
workers.push(Worker::new(id))
}
Self {threads}
Self {workers}
}
}
fn main() -> std::io::Result<()> {