1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 19:47:43 +02:00

update to tokio 1.0 for actix-rt (#236)

This commit is contained in:
fakeshadow
2020-12-28 09:40:22 +08:00
committed by GitHub
parent ba44ea7d0b
commit 0c12930796
9 changed files with 49 additions and 61 deletions

View File

@ -5,7 +5,7 @@ fn await_for_timer() {
let time = Duration::from_secs(2);
let instant = Instant::now();
actix_rt::System::new("test_wait_timer").block_on(async move {
tokio::time::delay_for(time).await;
tokio::time::sleep(time).await;
});
assert!(
instant.elapsed() >= time,
@ -20,7 +20,7 @@ fn join_another_arbiter() {
actix_rt::System::new("test_join_another_arbiter").block_on(async move {
let mut arbiter = actix_rt::Arbiter::new();
arbiter.send(Box::pin(async move {
tokio::time::delay_for(time).await;
tokio::time::sleep(time).await;
actix_rt::Arbiter::current().stop();
}));
arbiter.join().unwrap();
@ -35,7 +35,7 @@ fn join_another_arbiter() {
let mut arbiter = actix_rt::Arbiter::new();
arbiter.exec_fn(move || {
actix_rt::spawn(async move {
tokio::time::delay_for(time).await;
tokio::time::sleep(time).await;
actix_rt::Arbiter::current().stop();
});
});
@ -50,7 +50,7 @@ fn join_another_arbiter() {
actix_rt::System::new("test_join_another_arbiter").block_on(async move {
let mut arbiter = actix_rt::Arbiter::new();
arbiter.send(Box::pin(async move {
tokio::time::delay_for(time).await;
tokio::time::sleep(time).await;
actix_rt::Arbiter::current().stop();
}));
arbiter.stop();
@ -104,17 +104,17 @@ fn non_static_block_on() {
let string = String::from("test_str");
let str = string.as_str();
let mut sys = actix_rt::System::new("borrow some");
let sys = actix_rt::System::new("borrow some");
sys.block_on(async {
actix_rt::time::delay_for(Duration::from_millis(1)).await;
actix_rt::time::sleep(Duration::from_millis(1)).await;
assert_eq!("test_str", str);
});
let mut rt = actix_rt::Runtime::new().unwrap();
let rt = actix_rt::Runtime::new().unwrap();
rt.block_on(async {
actix_rt::time::delay_for(Duration::from_millis(1)).await;
actix_rt::time::sleep(Duration::from_millis(1)).await;
assert_eq!("test_str", str);
});