Permit::wait() after revoke() does not wait
Hi!
Why doesn't the "The thread is stopped" message appear in this example?
use std::thread;
use std::time::Duration;
fn main() {
let top_permit = permit::Permit::new();
let permit = top_permit.new_sub();
thread::spawn(move || {
while !permit.is_revoked() {
thread::sleep(Duration::from_secs(1));
println!("+");
}
println!("The thread is stopped");
});
thread::sleep(Duration::from_secs(5));
top_permit.revoke().wait();
}
Cargo.toml
[package]
name = "thread_control"
version = "0.1.0"
edition = "2018"
[dependencies]
permit = "0.1.3"
rustc --version
rustc 1.51.0 (2fd73fabe 2021-03-23)
Edited by Michael Leonhard