Skip to content

Commit

Permalink
Get rid of num_cpus dependency.
Browse files Browse the repository at this point in the history
Starting from 1.59.0, there is `std::thread::available_parallelism()`,
which basically does the same thing.
  • Loading branch information
dfyz committed Jan 22, 2023
1 parent f72004c commit 86f7a75
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license = "MIT"
anyhow = "*"
byteorder = "*"
memmap = "*"
num_cpus = "*"
owning_ref = "*"
png = "*"
tini = "*"
Expand Down
5 changes: 3 additions & 2 deletions src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ pub fn run_server(
perf_stats: Mutex::new(PerfStats::default()),
});

let thread_count = num_cpus::get();
let thread_count =
thread::available_parallelism().context("Failed to determine the number of threads to use for rendering")?;

let mut senders: Vec<Sender<HandlerMessage>> = Vec::new();
let mut receivers: Vec<Receiver<HandlerMessage>> = Vec::new();

for _ in 0..thread_count {
for _ in 0..thread_count.into() {
let (tx, rx) = mpsc::channel();
senders.push(tx);
receivers.push(rx);
Expand Down

0 comments on commit 86f7a75

Please sign in to comment.