Remove references to Arbiter

This commit is contained in:
asonix 2023-09-29 11:54:43 -05:00
parent cd3159fea8
commit 6f44b05c0a
2 changed files with 9 additions and 31 deletions

View file

@ -378,21 +378,10 @@ mod io_uring {
mod tests { mod tests {
use std::io::Read; use std::io::Read;
macro_rules! test_on_arbiter { macro_rules! test_async {
($fut:expr) => { ($fut:expr) => {
actix_web::rt::System::new().block_on(async move { actix_web::rt::System::new()
let arbiter = actix_web::rt::Arbiter::new(); .block_on(async move { crate::sync::spawn($fut).await.unwrap() })
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()
})
}; };
} }
@ -402,7 +391,7 @@ mod io_uring {
fn read() { fn read() {
let tmp = "/tmp/read-test"; 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 file = super::File::open(EARTH_GIF).await.unwrap();
let mut tmp_file = tokio::fs::File::create(tmp).await.unwrap(); let mut tmp_file = tokio::fs::File::create(tmp).await.unwrap();
file.read_to_async_write(&mut tmp_file).await.unwrap(); file.read_to_async_write(&mut tmp_file).await.unwrap();
@ -428,7 +417,7 @@ mod io_uring {
fn write() { fn write() {
let tmp = "/tmp/write-test"; 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 file = tokio::fs::File::open(EARTH_GIF).await.unwrap();
let mut tmp_file = super::File::create(tmp).await.unwrap(); let mut tmp_file = super::File::create(tmp).await.unwrap();
tmp_file.write_from_async_read(&mut file).await.unwrap(); tmp_file.write_from_async_read(&mut file).await.unwrap();

View file

@ -77,27 +77,16 @@ mod test {
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::io::Read; use std::io::Read;
macro_rules! test_on_arbiter { macro_rules! test_async {
($fut:expr) => { ($fut:expr) => {
actix_web::rt::System::new().block_on(async move { actix_web::rt::System::new()
let arbiter = actix_web::rt::Arbiter::new(); .block_on(async move { crate::sync::spawn($fut).await.unwrap() })
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()
})
}; };
} }
#[test] #[test]
fn hasher_works() { 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 file1 = tokio::fs::File::open("./client-examples/earth.gif").await?;
let mut reader = Hasher::new(file1); let mut reader = Hasher::new(file1);