update condvar

pull/1246/head
csf 1 year ago
parent 88c7413dcd
commit 46675a1db8

@ -456,18 +456,15 @@ fn main() {
let ccond = cond.clone(); let ccond = cond.clone();
let hdl = spawn(move || { let hdl = spawn(move || {
let mut m = { *cflag.lock().unwrap() }; let mut lock = cflag.lock().unwrap();
let mut counter = 0; let mut counter = 0;
while counter < 3 { while counter < 3 {
while !m { while !*lock {
m = *ccond.wait(cflag.lock().unwrap()).unwrap(); lock = ccond.wait(lock).unwrap();
} }
{ *lock = false;
m = false;
*cflag.lock().unwrap() = false;
}
counter += 1; counter += 1;
println!("inner counter: {}", counter); println!("inner counter: {}", counter);

Loading…
Cancel
Save