Define thread pool size in some getter

This commit is contained in:
p11 2025-05-29 20:17:01 +02:00
parent 05cacce192
commit 24017cd6f2

View File

@ -47,6 +47,12 @@ fn main() -> ExitCode {
ExitCode::FAILURE
}
fn get_thread_pool_size() -> usize {
std::env::var("THREAD_POOL")
.map(|s| s.parse().unwrap_or(4))
.unwrap_or(4)
}
fn start_server(
path: PathBuf,
address: &str,
@ -59,12 +65,8 @@ fn start_server(
};
eprintln!("Strated server!");
let context: Arc<Mutex<Context>> = Arc::default();
let thread_pool_size = std::env::var("THREAD_POOL")
.map(|s| s.parse().unwrap_or(4))
.unwrap_or(4);
let mut pool = ThreadPool::new(thread_pool_size);
let context = Arc::new(Mutex::new(Context::default()));
let mut pool = ThreadPool::new(get_thread_pool_size());
for stream in listener.incoming() {
eprintln!("New connection!");