From 5ba44d216f37fb09cd64efb95154911f8412bac1 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 11 Oct 2022 06:34:35 +0200 Subject: [PATCH] fix encoder using too many threads --- src/main.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index bd93ce0..40e742b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -433,13 +433,8 @@ async fn main() { *running.lock().unwrap() -= 1; println!("encode: encoded {n}"); }); - #[cfg(debug_assertions)] - { - thread::sleep(Duration::from_millis(5000)); - } - #[cfg(not(debug_assertions))] - { - thread::sleep(Duration::from_millis(200)); + while *running.lock().unwrap() < 5 { + tokio::time::sleep(Duration::from_millis(100)).await; } } while *running.lock().unwrap() != 0 {