id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
use tokio::time::{self, Duration, Instant, Interval};
use tokio_test::{assert_pending, assert_ready_eq, task};
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = Interval::new(Instant::now(), ms(0));
}
#[tokio::test]
async fn usage() {
time::pause();
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/time_interval.rs | 1 | 45 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
#![cfg(panic = "unwind")]
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, timeou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.enable_alt_timer()
.enable_all()
.build()
.unwrap();
rts.push(rt);
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_panic.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | let rt = current_thread();
rt.block_on(async {
time::resume();
});
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_panic.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_panic.rs:4 | // Runtime without `enable_time` so it has no current timer set.
let rt = Builder::new_current_thread().build().unwrap();
rt.block_on(async {
let _timeout = timeout(Duration::from_millis(5), future::pending::<()>());
});
});
// The panic location should be in this file
a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_panic.rs | 121 | 155 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
#![cfg(panic = "unwind")]
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | let rt = current_thread();
rt.block_on(async {
time::resume();
});
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/tests/time_panic.rs | 81 | 139 |
tokio-rs/tokio:tokio/tests/time_panic.rs:4 | // Runtime without `enable_time` so it has no current timer set.
let rt = Builder::new_current_thread().build().unwrap();
rt.block_on(async {
let _timeout = timeout(Duration::from_millis(5), future::pending::<()>());
});
});
// The panic location should be in this file
a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 73d733a3415af98d72c2cce40612c4e59adbd5d8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/73d733a3415af98d72c2cce40612c4e59adbd5d8/tokio/tests/time_panic.rs | 121 | 139 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
#![cfg(panic = "unwind")]
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = interval(Duration::from_millis(0));
});
// The panic loca... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_panic.rs | 41 | 94 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_panic.rs | 81 | 94 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
mod support {
pub... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | });
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[cfg(panic = "unwind")]
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = interval(Duration::from_millis(0)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/time_panic.rs | 41 | 98 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | let rt = Builder::new_current_thread().build().unwrap();
rt.block_on(async {
let _timeout = timeout(Duration::from_millis(5), future::pending::<()>());
});
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
fn curr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/time_panic.rs | 81 | 98 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | });
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[cfg(panic = "unwind")]
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = interval(Duration::from_millis(0)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/tests/time_panic.rs | 41 | 98 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | let rt = Builder::new_current_thread().build().unwrap();
rt.block_on(async {
let _ = timeout(Duration::from_millis(5), future::pending::<()>());
});
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
fn current_thr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/tests/time_panic.rs | 81 | 98 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
mod support {
pub... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = interval(Duration::from_millis(0));
});
// The panic location shou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_panic.rs | 41 | 93 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_panic.rs | 81 | 93 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
mod support {
pub mod pan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
mod support {
pub mod pan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = interval(Duration::from_millis(0));
});
// The panic location shou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/time_panic.rs | 41 | 93 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
fn basic() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/time_panic.rs | 81 | 93 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
mod support {
pub... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future;
use std::error::Error;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn pause_panic... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | b51aa8f6f9cb205a8444743429cc80a86f982f1d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b51aa8f6f9cb205a8444743429cc80a86f982f1d/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future;
use parking_lot::{const_mutex, Mutex};
use std::error::Error;
use std::panic;
use std::sync::Arc;
use std::time::Duration;
use tokio::runtime::{Builder, Runtime};
use tokio::time::{self, interval, interval_at, timeout, Instant};
fn test_panic<F... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 3cc616877d7f0122b4547f4ccd6a6c13b61b2036 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3cc616877d7f0122b4547f4ccd6a6c13b61b2036/tokio/tests/time_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_panic.rs:2 | }
}
#[test]
fn pause_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
rt.block_on(async {
time::pause();
time::pause();
});
});
// The panic location should be in this file
assert_eq!(&panic_loca... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 3cc616877d7f0122b4547f4ccd6a6c13b61b2036 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3cc616877d7f0122b4547f4ccd6a6c13b61b2036/tokio/tests/time_panic.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_panic.rs:3 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn interval_at_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = interval_at(Instant::now(), Duration::from_millis(0));
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_panic.rs | MIT | 3cc616877d7f0122b4547f4ccd6a6c13b61b2036 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3cc616877d7f0122b4547f4ccd6a6c13b61b2036/tokio/tests/time_panic.rs | 81 | 122 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(miri))] // Too slow on miri.
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_pending, assert_ready, assert_ready_eq, task};
#[cfg(not(target_os = "wasi"))]
u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:2 | #[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn pause_time_in_spawn_threads() {
let t = tokio::spawn(async {
tokio::time::pause();
});
assert_err!(t.await);
}
#[test]
fn paused_time_is_deter... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_pause.rs:3 | assert_pending!(sleep.poll());
let before = Instant::now();
time::advance(ms(100)).await;
assert_elapsed!(before, ms(100));
assert_pending!(sleep.poll());
}
#[tokio::test(start_paused = true)]
async fn sleep_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_pause.rs:4 | type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match &mut self.state {
State::Begin => {
if self.poll {
assert_pending!(self.sleep.as_mut().poll(cx));
}
self.before = Some(Inst... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_pause.rs:5 | Tester {
sleep,
state: State::Begin,
before: None,
poll: true,
}
.await;
}
#[tokio::test(start_paused = true)]
async fn sleep_same_task_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let sleep = Box::pin(time::sleep_until... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_pause.rs:6 | time::advance(ms(100)).await;
assert_elapsed!(before, ms(100));
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(200)).await;
assert_elapsed!(before, ms(200));
assert_ready_eq!(poll_next(&mut i), start + ms(300));
assert_pending!(poll_next(&mut i));
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_pause.rs:7 | #[tokio::test(start_paused = true)]
async fn test_time_advance_3ms_and_change() {
let now = Instant::now();
let dur = Duration::from_micros(3_141_592);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
let now = Instant::now();
let dur = Duration::from_micros(3_123_456);
time::adv... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_pause.rs:8 | assert_eq!(now.elapsed(), dur);
let now = Instant::now();
let dur = Duration::from_millis(1);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
}
#[tokio::test(start_paused = true)]
async fn advance_once_with_timer() {
let mut sleep = task::spawn(time::sleep(Duration::from_millis(1)));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 281 | 333 |
tokio-rs/tokio:tokio/tests/time_pause.rs:9 | time::advance(Duration::from_micros(250)).await;
assert!(sleep.is_woken());
assert_ready!(sleep.poll());
}
fn poll_next(interval: &mut task::Spawn<time::Interval>) -> Poll<Instant> {
interval.enter(|cx, mut interval| interval.poll_tick(cx))
}
fn ms(n: u64) -> Duration {
Duration::from_millis(n)
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_pause.rs | 321 | 333 |
tokio-rs/tokio:tokio/tests/time_pause.rs:2 | #[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn pause_time_in_spawn_threads() {
let t = tokio::spawn(async {
tokio::time::pause();
});
assert_err!(t.await);
}
#[test]
fn paused_time_is_deter... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/time_pause.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_pending, assert_ready, assert_ready_eq, task};
#[cfg(not(target_os = "wasi"))]
use tokio_test::assert_err;
use std::{
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:2 | #[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn pause_time_in_spawn_threads() {
let t = tokio::spawn(async {
tokio::time::pause();
});
assert_err!(t.await);
}
#[test]
fn paused_time_is_deterministic() {
let run_1 = paused_time_stress_run();
let run_2 = paused_time_stre... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_pause.rs:3 | assert_pending!(sleep.poll());
let before = Instant::now();
time::advance(ms(100)).await;
assert_elapsed!(before, ms(100));
assert_pending!(sleep.poll());
}
#[tokio::test(start_paused = true)]
async fn sleep_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_pause.rs:4 | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match &mut self.state {
State::Begin => {
if self.poll {
assert_pending!(self.sleep.as_mut().poll(cx));
}
self.before = Some(Instant::now());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_pause.rs:5 | sleep,
state: State::Begin,
before: None,
poll: true,
}
.await;
}
#[tokio::test(start_paused = true)]
async fn sleep_same_task_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let sleep = Box::pin(time::sleep_until(start + ms(300))... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_pause.rs:6 | assert_elapsed!(before, ms(100));
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(200)).await;
assert_elapsed!(before, ms(200));
assert_ready_eq!(poll_next(&mut i), start + ms(300));
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_pause.rs:7 | async fn test_time_advance_3ms_and_change() {
let now = Instant::now();
let dur = Duration::from_micros(3_141_592);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
let now = Instant::now();
let dur = Duration::from_micros(3_123_456);
time::advance(dur).await;
assert_eq!(now... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/time_pause.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_pending, assert_ready, assert_ready_eq, task};
#[cfg(not(target_os = "wasi"))]
use tokio_test::assert_err;
use std::{
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_pending, assert_ready, assert_ready_eq, task};
#[cfg(not(target_os = "wasi"))]
use tokio_test::assert_err;
use std::{
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:2 | async fn pause_time_in_spawn_threads() {
let t = tokio::spawn(async {
tokio::time::pause();
});
assert_err!(t.await);
}
#[test]
fn paused_time_is_deterministic() {
let run_1 = paused_time_stress_run();
let run_2 = paused_time_stress_run();
assert_eq!(run_1, run_2);
}
#[tokio::main(fl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_pause.rs:3 | let before = Instant::now();
time::advance(ms(100)).await;
assert_elapsed!(before, ms(100));
assert_pending!(sleep.poll());
}
#[tokio::test(start_paused = true)]
async fn sleep_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let mut sleep = task::sp... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_pause.rs:4 | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match &mut self.state {
State::Begin => {
if self.poll {
assert_pending!(self.sleep.as_mut().poll(cx));
}
self.before = Some(Instant::now());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_pause.rs:5 | state: State::Begin,
before: None,
poll: true,
}
.await;
}
#[tokio::test(start_paused = true)]
async fn sleep_same_task_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let sleep = Box::pin(time::sleep_until(start + ms(300)));
Tester ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_pause.rs:6 | assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(200)).await;
assert_elapsed!(before, ms(200));
assert_ready_eq!(poll_next(&mut i), start + ms(300));
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(400)).await;
assert_e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_pause.rs:7 | let now = Instant::now();
let dur = Duration::from_micros(3_141_592);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
let now = Instant::now();
let dur = Duration::from_micros(3_123_456);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
}
#[tokio::test(start_paused = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_pause.rs:8 | let now = Instant::now();
let dur = Duration::from_millis(1);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
}
#[tokio::test(start_paused = true)]
async fn advance_once_with_timer() {
let mut sleep = task::spawn(time::sleep(Duration::from_millis(1)));
assert_pending!(sleep.poll());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 281 | 331 |
tokio-rs/tokio:tokio/tests/time_pause.rs:9 | assert!(sleep.is_woken());
assert_ready!(sleep.poll());
}
fn poll_next(interval: &mut task::Spawn<time::Interval>) -> Poll<Instant> {
interval.enter(|cx, mut interval| interval.poll_tick(cx))
}
fn ms(n: u64) -> Duration {
Duration::from_millis(n)
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_pause.rs | 321 | 331 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_pending, assert_ready, assert_ready_eq, task};
#[cfg(not(tokio_wasi))]
use tokio_test::assert_err;
use std::{
futur... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_err, assert_pending, assert_ready, assert_ready_eq, task};
use std::{
future::Future,
pin::Pin,
task::{Conte... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:2 | assert_err!(t.await);
}
#[test]
fn paused_time_is_deterministic() {
let run_1 = paused_time_stress_run();
let run_2 = paused_time_stress_run();
assert_eq!(run_1, run_2);
}
#[tokio::main(flavor = "current_thread", start_paused = true)]
async fn paused_time_stress_run() -> Vec<Duration> {
let mut rng =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_pause.rs:3 | assert_pending!(sleep.poll());
}
#[tokio::test(start_paused = true)]
async fn sleep_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let mut sleep = task::spawn(time::sleep_until(start + ms(300)));
let before = Instant::now();
time::advance(ms(100)).awai... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_pause.rs:4 | }
self.before = Some(Instant::now());
let advance_fut = Box::pin(time::advance(ms(100)));
self.state = State::AwaitingAdvance(advance_fut);
self.poll(cx)
}
State::AwaitingAdvance(ref mut advance_fut) => match advance_fut.as_mut().po... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_pause.rs:5 | }
#[tokio::test(start_paused = true)]
async fn sleep_same_task_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let sleep = Box::pin(time::sleep_until(start + ms(300)));
Tester {
sleep,
state: State::Begin,
before: None,
poll:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_pause.rs:6 | assert_ready_eq!(poll_next(&mut i), start + ms(300));
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(400)).await;
assert_elapsed!(before, ms(400));
assert_ready_eq!(poll_next(&mut i), start + ms(600));
assert_pending!(poll_next(&mut i));
let before = Inst... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_pause.rs:7 | assert_eq!(now.elapsed(), dur);
let now = Instant::now();
let dur = Duration::from_micros(3_123_456);
time::advance(dur).await;
assert_eq!(now.elapsed(), dur);
}
#[tokio::test(start_paused = true)]
async fn regression_3710_with_submillis_advance() {
let start = Instant::now();
time::advance(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_pause.rs:8 | assert_eq!(now.elapsed(), dur);
}
#[tokio::test(start_paused = true)]
async fn advance_once_with_timer() {
let mut sleep = task::spawn(time::sleep(Duration::from_millis(1)));
assert_pending!(sleep.poll());
time::advance(Duration::from_micros(250)).await;
assert_pending!(sleep.poll());
time::advan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 18779aa2e292c4c060a35c2882601373c36e7af0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18779aa2e292c4c060a35c2882601373c36e7af0/tokio/tests/time_pause.rs | 281 | 326 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_elapsed, assert_err, assert_pending, assert_ready_eq, task};
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 8ef39dfb22974e6f5f6203e279912d3eac68017d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ef39dfb22974e6f5f6203e279912d3eac68017d/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:5 | }
#[tokio::test(start_paused = true)]
async fn sleep_same_task_no_poll() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let sleep = Box::pin(time::sleep_until(start + ms(300)));
Tester {
sleep,
state: State::Begin,
before: None,
poll:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 8ef39dfb22974e6f5f6203e279912d3eac68017d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ef39dfb22974e6f5f6203e279912d3eac68017d/tokio/tests/time_pause.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_pause.rs:6 | assert_ready_eq!(poll_next(&mut i), start + ms(300));
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(400)).await;
assert_elapsed!(before, ms(400));
assert_ready_eq!(poll_next(&mut i), start + ms(600));
assert_pending!(poll_next(&mut i));
let before = Inst... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 8ef39dfb22974e6f5f6203e279912d3eac68017d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ef39dfb22974e6f5f6203e279912d3eac68017d/tokio/tests/time_pause.rs | 201 | 224 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_test::{assert_err, assert_pending, assert_ready_eq, task};
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
macro_rules! as... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 2b9b55810847b4c7855e3de82f432ca997600f30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b9b55810847b4c7855e3de82f432ca997600f30/tokio/tests/time_pause.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_pause.rs:2 | t.await.unwrap();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[should_panic]
async fn pause_time_in_main_threads() {
tokio::time::pause();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn pause_time_in_spawn_threads() {
let t = tokio::spawn(async {
tokio::time:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 2b9b55810847b4c7855e3de82f432ca997600f30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b9b55810847b4c7855e3de82f432ca997600f30/tokio/tests/time_pause.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_pause.rs:3 | #[tokio::test(start_paused = true)]
async fn advance_after_poll() {
time::sleep(ms(1)).await;
let start = Instant::now();
let mut sleep = task::spawn(time::sleep_until(start + ms(300)));
assert_pending!(sleep.poll());
let before = Instant::now();
time::advance(ms(100)).await;
assert_elap... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 2b9b55810847b4c7855e3de82f432ca997600f30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b9b55810847b4c7855e3de82f432ca997600f30/tokio/tests/time_pause.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_pause.rs:4 | struct Tester {
sleep: Pin<Box<Sleep>>,
state: State,
before: Option<Instant>,
poll: bool,
}
impl Future for Tester {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match &mut self.state {
State::Begin => {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 2b9b55810847b4c7855e3de82f432ca997600f30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b9b55810847b4c7855e3de82f432ca997600f30/tokio/tests/time_pause.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_pause.rs:5 | async fn sleep_same_task() {
let start = Instant::now();
// TODO: Skip this
time::advance(ms(1)).await;
let sleep = Box::pin(time::sleep_until(start + ms(300)));
Tester {
sleep,
state: State::Begin,
before: None,
poll: true,
}
.await;
}
#[tokio::test(start... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 2b9b55810847b4c7855e3de82f432ca997600f30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b9b55810847b4c7855e3de82f432ca997600f30/tokio/tests/time_pause.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_pause.rs:6 | time::advance(ms(1)).await;
let mut i = task::spawn(time::interval_at(start, ms(300)));
assert_ready_eq!(poll_next(&mut i), start);
assert_pending!(poll_next(&mut i));
let before = Instant::now();
time::advance(ms(100)).await;
assert_elapsed!(before, 100);
assert_pending!(poll_next(&mut i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | 2b9b55810847b4c7855e3de82f432ca997600f30 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b9b55810847b4c7855e3de82f432ca997600f30/tokio/tests/time_pause.rs | 201 | 239 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use rand::SeedableRng;
use rand::{rngs::StdRng, Rng};
use tokio::time::{self, Duration, Instant};
use tokio_test::assert_err;
#[tokio::test]
async fn pause_time_in_main() {
tokio::time::pause();
}
#[tokio::test]
async fn pause_time_in_task() {
let t = toki... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/tests/time_pause.rs | 1 | 59 |
tokio-rs/tokio:tokio/tests/time_pause.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio_test::assert_err;
#[tokio::test]
async fn pause_time_in_main() {
tokio::time::pause();
}
#[tokio::test]
async fn pause_time_in_task() {
let t = tokio::spawn(async {
tokio::time::pause();
});
t.await.unwrap();
}
#[tokio::test(fla... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_pause.rs | MIT | abd4c0025539f142ec48a09e01430f7ee3b83214 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/abd4c0025539f142ec48a09e01430f7ee3b83214/tokio/tests/time_pause.rs | 1 | 33 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::runtime::Runtime;
use tokio::time::*;
use std::sync::mpsc;
fn rt_combinations() -> Vec<Runtime> {
let mut rts = vec![];
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
rts.pus... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_alt_timer()
.enable_all()
.build()
.unwrap();
rts.push(rt);
}
rts
}
#[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] // Wasi doesn't support thre... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_rt.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_rt.rs:3 | let (tx, rx) = mpsc::channel();
rt.block_on(async move {
let when = Instant::now() + Duration::from_millis(10);
sleep_until(when).await;
assert!(Instant::now() >= when);
tx.send(()).unwrap();
});
rx.recv().unwrap();
}
}
#[test]
fn timer_wi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_rt.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_rt.rs:4 | struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
impl<T: Future<Output = ()> + Unpin> Future for Starve<T> {
type Output = u64;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<u64> {
if Pin::new(&mut self.0).poll(cx).is_ready() {
return Poll::Ready... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_rt.rs | 121 | 166 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] // Wasi doesn't support threads
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | tx.send(()).unwrap();
});
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
impl<T: Future<Output = ()> + Unpin> Future for Starve<T> {
type... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_rt.rs | 41 | 90 |
tokio-rs/tokio:tokio/tests/time_rt.rs:3 | let (_tx, rx) = oneshot::channel::<()>();
let now = Instant::now();
let dur = Duration::from_millis(10);
let res = timeout(dur, rx).await;
assert!(res.is_err());
assert!(Instant::now() >= now + dur);
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/time_rt.rs | 81 | 90 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] // Wasi doesn't support threads
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] // Wasi doesn't support threads
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] // Wasi doesn't support threads
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 0d9430b99cc699824cc8545afbb01e0a7c520428 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | });
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
impl<T: Future<Output = ()> + Unpin> Future for Starve<T> {
type Output = u64;
fn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 0d9430b99cc699824cc8545afbb01e0a7c520428 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/time_rt.rs | 41 | 89 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | });
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
impl<T: Future<Output = ()> + Unpin> Future for Starve<T> {
type Output = u64;
fn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/tests/time_rt.rs | 41 | 89 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | });
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
impl<T: Future<Output = ()> + Unpin> Future for Starve<T> {
type Output = u64;
fn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/time_rt.rs | 41 | 89 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | sleep_until(when).await;
assert!(Instant::now() >= when);
tx.send(()).unwrap();
});
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_rt.rs | 41 | 93 |
tokio-rs/tokio:tokio/tests/time_rt.rs:3 | #[tokio::test]
async fn timeout_value() {
use tokio::sync::oneshot;
let (_tx, rx) = oneshot::channel::<()>();
let now = Instant::now();
let dur = Duration::from_millis(20);
let res = timeout(dur, rx).await;
assert!(res.is_err());
assert!(Instant::now() >= now + dur);
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_rt.rs | 81 | 93 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | delay_until(when).await;
assert!(Instant::now() >= when);
tx.send(()).unwrap();
});
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/time_rt.rs | 41 | 93 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration::from_millis(100);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/time_rt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_rt.rs:2 | assert!(Instant::now() >= when);
tx.send(()).unwrap();
});
rx.recv().unwrap();
}
#[tokio::test]
async fn starving() {
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
struct Starve<T: Future<Output = ()> + Unpin>(T, u64);
impl<T: Future<Output = ()> + ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/time_rt.rs | 41 | 92 |
tokio-rs/tokio:tokio/tests/time_rt.rs:3 | async fn timeout_value() {
use tokio::sync::oneshot;
let (_tx, rx) = oneshot::channel::<()>();
let now = Instant::now();
let dur = Duration::from_millis(20);
let res = timeout(dur, rx).await;
assert!(res.is_err());
assert!(Instant::now() >= now + dur);
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/time_rt.rs | 81 | 92 |
tokio-rs/tokio:tokio/tests/time_rt.rs:1 | #![warn(rust_2018_idioms)]
use tokio::time::*;
use std::sync::mpsc;
#[test]
fn timer_with_threaded_runtime() {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.spawn(async move {
let when = Instant::now() + Duration::from_millis(100);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_rt.rs | MIT | 3f0eabe7798de624f5ee9c7562803bfb97e6088f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3f0eabe7798de624f5ee9c7562803bfb97e6088f/tokio/tests/time_rt.rs | 1 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.