|
|
@ -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);
|
|
|
|