Fix not all pending data getting processed when finishing

master
trivernis 5 years ago
parent 727483de7c
commit ed1123bf25

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

@ -59,7 +59,7 @@ impl<T1, T2> ThreadManager<T1, T2> {
self.sender_work = None; self.sender_work = None;
} }
/// Waits for the waitgroup /// Waits for the wait group
pub fn wait(&mut self) { pub fn wait(&mut self) {
let wg = self.wg.clone(); let wg = self.wg.clone();
self.wg = WaitGroup::new(); self.wg = WaitGroup::new();
@ -181,6 +181,7 @@ impl BDFWriter {
/// Flushes the buffered chunk data and the writer /// Flushes the buffered chunk data and the writer
/// to finish the file. /// to finish the file.
pub fn finish(&mut self) -> Result<(), Error> { pub fn finish(&mut self) -> Result<(), Error> {
self.flush()?;
self.thread_manager.drop_sender(); self.thread_manager.drop_sender();
self.thread_manager.wait(); self.thread_manager.wait();
self.flush()?; self.flush()?;

Loading…
Cancel
Save