cleanup
This commit is contained in:
parent
a0a3ea0fbb
commit
7eaa394d7d
18
src/main.rs
18
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<dyn std::error::Error>> {
|
||||
_ => (),
|
||||
};
|
||||
|
||||
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(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user