Skip to content

Commit

Permalink
Fix the lock release in asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanUkhov committed Dec 28, 2024
1 parent 28f4226 commit 2c8808a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "loop"
version = "0.5.1"
version = "0.5.2"
edition = "2021"
license = "Apache-2.0/MIT"
authors = ["Ivan Ukhov <ivan.ukhov@gmail.com>"]
Expand Down
5 changes: 4 additions & 1 deletion src/asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ where
let item_receiver = item_receiver.clone();
let output_sender = output_sender.clone();
std::mem::drop(tokio::task::spawn(async move {
while let Some(item) = item_receiver.lock().await.recv().await {
while let Some(item) = {
let mut receiver = item_receiver.lock().await;
receiver.recv().await
} {
if output_sender.send(map(item).await).await.is_err() {
break;
}
Expand Down

0 comments on commit 2c8808a

Please sign in to comment.