This commit is contained in:
Shautvast 2026-02-09 20:13:08 +01:00
parent 24f0ca7de1
commit bbf889e72e

View file

@ -1,15 +1,17 @@
use log::info;
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::sync::mpsc;
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{
struct Worker {
id: usize,
thread: thread::JoinHandle<()>,
}
@ -30,14 +32,16 @@ impl ThreadPool {
pub fn new(size: usize) -> Self {
assert!(size > 0);
let mut workers = Vec::with_capacity(size);
let (sender, receiver) = mpsc::channel();
for id in 0..size {
workers.push(Worker::new(id))
}
Self {workers}
Self { workers, sender }
}
}
struct Job {}
fn main() -> std::io::Result<()> {
env_logger::init();
let listener = TcpListener::bind("127.0.0.1:7878")?;