From 630d95cde42f4ef1d579726616195dc3cd4bb5b0 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sun, 14 Jul 2024 08:12:39 +0000 Subject: [PATCH] more idiomatic example --- Cargo.lock | 2 +- README.md | 3 ++- examples/channel.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6f4435..21f2171 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "microlock" -version = "0.2.0" +version = "0.2.1" diff --git a/README.md b/README.md index b768f99..24c3fc0 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ fn main() { thread::spawn(move || loop { LOCK.wait_here(); println!("{}", queue2.lock().unwrap().pop_front().unwrap()); - LOCK.lock(); + // try_lock because another unlock *could*ve happened since then + LOCK.try_lock(); }); let timer = TimedLock::unlocked(); diff --git a/examples/channel.rs b/examples/channel.rs index dfb7f21..1a6fae8 100644 --- a/examples/channel.rs +++ b/examples/channel.rs @@ -13,7 +13,8 @@ fn main() { thread::spawn(move || loop { LOCK.wait_here(); println!("{}", queue2.lock().unwrap().pop_front().unwrap()); - LOCK.lock(); + // try_lock because another unlock *could*ve happened since then + LOCK.try_lock(); }); let timer = TimedLock::unlocked();