diff --git a/Cargo.toml b/Cargo.toml index abcf0a2..e3450b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -threadpool = "1.0" +rusty_pool = "0.6.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.64" openssl = {version = "0.10", features = ["vendored"]} diff --git a/src/main.rs b/src/main.rs index 9feac3e..ea96209 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,8 @@ use std::sync::Mutex; use std::thread; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; -use threadpool::ThreadPool; +use rusty_pool; +use std::time::Duration; mod database; mod http; @@ -42,7 +43,11 @@ fn main() { database::init(); - let thread_pool = ThreadPool::new(256); + let thread_pool = rusty_pool::Builder::new() + .core_size(4) + .max_size(1024) + .keep_alive(Duration::from_secs(60 * 60)) + .build(); let thread_pool_mutex = Arc::new(Mutex::new(thread_pool)); let mut threads = Vec::new();