From 6f44b05c0ac65756809889bba06958a5799fc93f Mon Sep 17 00:00:00 2001 From: asonix Date: Fri, 29 Sep 2023 11:54:43 -0500 Subject: [PATCH] Remove references to Arbiter --- src/file.rs | 21 +++++---------------- src/ingest/hasher.rs | 19 ++++--------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/file.rs b/src/file.rs index 093c26f..9f0cd0b 100644 --- a/src/file.rs +++ b/src/file.rs @@ -378,21 +378,10 @@ mod io_uring { mod tests { use std::io::Read; - macro_rules! test_on_arbiter { + macro_rules! test_async { ($fut:expr) => { - actix_web::rt::System::new().block_on(async move { - let arbiter = actix_web::rt::Arbiter::new(); - - let (tx, rx) = crate::sync::channel(1); - - arbiter.spawn(async move { - let handle = crate::sync::spawn($fut); - - let _ = tx.send(handle.await.unwrap()); - }); - - rx.into_recv_async().await.unwrap() - }) + actix_web::rt::System::new() + .block_on(async move { crate::sync::spawn($fut).await.unwrap() }) }; } @@ -402,7 +391,7 @@ mod io_uring { fn read() { let tmp = "/tmp/read-test"; - test_on_arbiter!(async move { + test_async!(async move { let mut file = super::File::open(EARTH_GIF).await.unwrap(); let mut tmp_file = tokio::fs::File::create(tmp).await.unwrap(); file.read_to_async_write(&mut tmp_file).await.unwrap(); @@ -428,7 +417,7 @@ mod io_uring { fn write() { let tmp = "/tmp/write-test"; - test_on_arbiter!(async move { + test_async!(async move { let mut file = tokio::fs::File::open(EARTH_GIF).await.unwrap(); let mut tmp_file = super::File::create(tmp).await.unwrap(); tmp_file.write_from_async_read(&mut file).await.unwrap(); diff --git a/src/ingest/hasher.rs b/src/ingest/hasher.rs index d7577c2..5a6ef73 100644 --- a/src/ingest/hasher.rs +++ b/src/ingest/hasher.rs @@ -77,27 +77,16 @@ mod test { use sha2::{Digest, Sha256}; use std::io::Read; - macro_rules! test_on_arbiter { + macro_rules! test_async { ($fut:expr) => { - actix_web::rt::System::new().block_on(async move { - let arbiter = actix_web::rt::Arbiter::new(); - - let (tx, rx) = crate::sync::channel(1); - - arbiter.spawn(async move { - let handle = crate::sync::spawn($fut); - - let _ = tx.send(handle.await.unwrap()); - }); - - rx.into_recv_async().await.unwrap() - }) + actix_web::rt::System::new() + .block_on(async move { crate::sync::spawn($fut).await.unwrap() }) }; } #[test] fn hasher_works() { - let (hash, size) = test_on_arbiter!(async move { + let (hash, size) = test_async!(async move { let file1 = tokio::fs::File::open("./client-examples/earth.gif").await?; let mut reader = Hasher::new(file1);