more idiomatic example
This commit is contained in:
parent
a7a57b23f7
commit
630d95cde4
3 changed files with 5 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,4 +4,4 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "microlock"
|
name = "microlock"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
|
|
|
@ -26,7 +26,8 @@ fn main() {
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
LOCK.wait_here();
|
LOCK.wait_here();
|
||||||
println!("{}", queue2.lock().unwrap().pop_front().unwrap());
|
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();
|
let timer = TimedLock::unlocked();
|
||||||
|
|
|
@ -13,7 +13,8 @@ fn main() {
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
LOCK.wait_here();
|
LOCK.wait_here();
|
||||||
println!("{}", queue2.lock().unwrap().pop_front().unwrap());
|
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();
|
let timer = TimedLock::unlocked();
|
||||||
|
|
Loading…
Add table
Reference in a new issue