From 3aa279093c9d2def4868a05e016bf9ee3acf4853 Mon Sep 17 00:00:00 2001 From: Ar37-rs Date: Mon, 26 Sep 2022 00:58:10 +0700 Subject: [PATCH] Bump version. --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- src/lib.rs | 11 ++++------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de39204..92f7539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## [4.0.2] - 2022-9-26 +- Fix unexpected deadlock on `result` fn. + ## [4.0.1] - 2022-9-26 - Small Optimization * Added `IntoResult` trait to convert `Option` into `Result` diff --git a/Cargo.toml b/Cargo.toml index 29be1ff..e0ab52c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flowync" -version = "4.0.1" +version = "4.0.2" authors = ["Ar37-rs "] edition = "2021" description = "A simple utility for multithreading a/synchronization" diff --git a/src/lib.rs b/src/lib.rs index 84e26c8..0d9d61e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -227,14 +227,11 @@ where /// /// **Warning!** don't use this fn if channel value is important, use `extract fn` and then use `finalize fn` instead. pub fn result(&self, f: impl FnOnce(Result)) { + if self.state.channel_present.load(Ordering::Relaxed) { + let _ = self.state.mtx.lock().unwrap().0.take(); + self.state.cvar.notify_all(); + } if self.state.result_ready.load(Ordering::Relaxed) { - { - if self.state.channel_present.load(Ordering::Relaxed) { - let _ = self.state.mtx.lock().unwrap().0.take(); - self.state.cvar.notify_all(); - } - } - let _self = self; let catch = move || { let mut result_value = _self.state.mtx.lock().unwrap();