Change to only use half the decompression threads

master
trivernis 5 years ago
parent 03f923c772
commit e03d61574d

@ -1,6 +1,6 @@
[package] [package]
name = "bdflib" name = "bdflib"
version = "0.4.1" version = "0.4.2"
authors = ["trivernis <trivernis@gmail.com>"] authors = ["trivernis <trivernis@gmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -247,7 +247,7 @@ impl BDFReader {
/// Starts threads for decompressing chunks /// Starts threads for decompressing chunks
fn start_threads(&mut self) { fn start_threads(&mut self) {
for _ in 0..num_cpus::get() { for _ in 0..num_cpus::get()/2 {
thread::spawn({ thread::spawn({
let r = self.thread_manager.receiver_work.clone(); let r = self.thread_manager.receiver_work.clone();
let s = self.thread_manager.sender_result.clone(); let s = self.thread_manager.sender_result.clone();
@ -260,6 +260,10 @@ impl BDFReader {
drop(wg); drop(wg);
} }
}); });
}
// add some initial data to be decompressed.
// the data that is added is four times the number of threads
for _ in 0..num_cpus::get() * 2 {
if let Err(_) = self.add_compression_chunk() { if let Err(_) = self.add_compression_chunk() {
self.thread_manager.drop_sender(); self.thread_manager.drop_sender();
break; break;

Loading…
Cancel
Save