Skip to content

Commit

Permalink
Merge pull request #268 from meesfrensel/remove-num_cpus
Browse files Browse the repository at this point in the history
Remove dependency on num_cpus
  • Loading branch information
bradfier authored Apr 24, 2023
2 parents 72be0c7 + b073c86 commit c3bb228
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ time = { version = "0.3.15", features = [ "local-offset" ] }
tiny_http = { version = "0.12.0", default-features = false }
url = "2"
threadpool = "1"
num_cpus = "1"
sha1_smol = "1.0.0"

[dev-dependencies]
Expand Down
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ extern crate rand;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate num_cpus;
pub extern crate percent_encoding;
extern crate serde_json;
extern crate sha1_smol;
Expand Down Expand Up @@ -244,9 +243,15 @@ where
A: ToSocketAddrs,
F: Send + Sync + 'static + Fn(&Request) -> Response,
{
let pool_size = pool_size.unwrap_or_else(|| {
8 * thread::available_parallelism()
.map(|n| n.get())
.unwrap_or(1)
});

Server::new(addr, handler)
.expect("Failed to start server")
.pool_size(pool_size.unwrap_or_else(|| 8 * num_cpus::get()))
.pool_size(pool_size)
.run();
panic!("The server socket closed unexpectedly")
}
Expand Down

0 comments on commit c3bb228

Please sign in to comment.