From 7eaa394d7d3e5317fb82fbd969180d471f57ef58 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 20 Sep 2022 11:39:53 +0300 Subject: [PATCH] cleanup --- src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2add117..1cf8ba4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -263,6 +263,8 @@ async fn data_reader(queue: WriteQueue) { } // mark queue as done for writer to exit loop queue.lock().await.push_back(None); + + println!("convert done ✅"); } async fn data_writer(queue: WriteQueue) { @@ -303,6 +305,8 @@ async fn data_writer(queue: WriteQueue) { } } writer.close().await.unwrap(); + + println!("write done ✅"); } #[tokio::main] @@ -313,17 +317,15 @@ async fn main() -> Result<(), Box> { _ => (), }; - let queue: WriteQueue = Arc::new(Mutex::new(VecDeque::with_capacity(40))); + let queue: WriteQueue = Arc::new(Mutex::new(VecDeque::with_capacity(5000))); let queue_r = Arc::clone(&queue); let queue_w = Arc::clone(&queue); - let res = tokio::try_join!( - tokio::spawn(async move { data_reader(queue_r).await }), - tokio::spawn(async move { data_writer(queue_w).await }) - ); + tokio::try_join!( + tokio::spawn(data_reader(queue_r)), + tokio::spawn(data_writer(queue_w)) + )?; - res?; - - println!("done ✅"); + println!("all done ✅"); Ok(()) }