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_delay.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready, task};
macro_rules! assert_elapsed {
($now:expr, $ms:expr) => {{
let elapsed = $now.elapsed();
let lower = ms($ms);
// Handles ms rounding
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_delay.rs:2 | assert_elapsed!(now, i);
}
}
#[tokio::test]
async fn sub_ms_delayed_delay() {
time::pause();
for _ in 0..5 {
let now = Instant::now();
let deadline = now + ms(1) + Duration::new(0, 1);
time::sleep_until(deadline).await;
assert_elapsed!(now, 1);
}
}
#[tokio::test]
asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_delay.rs:3 | let mut delay = delay.into_inner();
delay.reset(Instant::now() + ms(200));
delay.await;
assert_elapsed!(now, 200);
}
#[tokio::test]
async fn reset_past_delay_before_turn() {
time::pause();
let now = Instant::now();
let mut delay = task::spawn(time::sleep_until(now + ms(100)));
assert_pe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_delay.rs:4 | assert_elapsed!(now, 80);
}
#[tokio::test]
async fn reset_future_delay_after_fire() {
time::pause();
let now = Instant::now();
let mut delay = time::sleep_until(now + ms(100));
(&mut delay).await;
assert_elapsed!(now, 100);
delay.reset(now + ms(110));
delay.await;
assert_elapsed!(now... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_delay.rs:5 | #[should_panic]
fn creating_delay_outside_of_context() {
let now = Instant::now();
// This creates a delay outside of the context of a mock timer. This tests
// that it will panic.
let _fut = time::sleep_until(now + ms(500));
}
#[should_panic]
#[tokio::test]
async fn greater_than_max() {
const YR_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay.rs | 161 | 196 |
tokio-rs/tokio:tokio/tests/time_delay.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready, task};
macro_rules! assert_elapsed {
($now:expr, $ms:expr) => {{
let elapsed = $now.elapsed();
let lower = ms($ms);
// Handles ms rounding
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_delay.rs:2 | assert_elapsed!(now, i);
}
}
#[tokio::test]
async fn sub_ms_delayed_delay() {
time::pause();
for _ in 0..5 {
let now = Instant::now();
let deadline = now + ms(1) + Duration::new(0, 1);
time::delay_until(deadline).await;
assert_elapsed!(now, 1);
}
}
#[tokio::test]
asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_delay.rs:3 | let mut delay = delay.into_inner();
delay.reset(Instant::now() + ms(200));
delay.await;
assert_elapsed!(now, 200);
}
#[tokio::test]
async fn reset_past_delay_before_turn() {
time::pause();
let now = Instant::now();
let mut delay = task::spawn(time::delay_until(now + ms(100)));
assert_pe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_delay.rs:4 | assert_elapsed!(now, 80);
}
#[tokio::test]
async fn reset_future_delay_after_fire() {
time::pause();
let now = Instant::now();
let mut delay = time::delay_until(now + ms(100));
(&mut delay).await;
assert_elapsed!(now, 100);
delay.reset(now + ms(110));
delay.await;
assert_elapsed!(now... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_delay.rs:5 | #[should_panic]
fn creating_delay_outside_of_context() {
let now = Instant::now();
// This creates a delay outside of the context of a mock timer. This tests
// that it will panic.
let _fut = time::delay_until(now + ms(500));
}
#[should_panic]
#[tokio::test]
async fn greater_than_max() {
const YR_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay.rs | 161 | 196 |
tokio-rs/tokio:tokio/tests/time_delay.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, task};
macro_rules! assert_elapsed {
($now:expr, $ms:expr) => {{
let elapsed = $now.elapsed();
let lower = ms($ms);
// Handles ms rounding
assert!(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | e2230f3392901e2bfb4b26fdf0d4977ec6c8545c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2230f3392901e2bfb4b26fdf0d4977ec6c8545c/tokio/tests/time_delay.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_delay.rs:3 | let mut delay = delay.into_inner();
delay.reset(Instant::now() + ms(200));
delay.await;
assert_elapsed!(now, 200);
}
#[tokio::test]
async fn reset_past_delay_before_turn() {
time::pause();
let now = Instant::now();
let mut delay = task::spawn(time::delay_until(now + ms(100)));
assert_pe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | e2230f3392901e2bfb4b26fdf0d4977ec6c8545c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2230f3392901e2bfb4b26fdf0d4977ec6c8545c/tokio/tests/time_delay.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_delay.rs:4 | assert_elapsed!(now, 80);
}
#[tokio::test]
async fn reset_future_delay_after_fire() {
time::pause();
let now = Instant::now();
let mut delay = time::delay_until(now + ms(100));
(&mut delay).await;
assert_elapsed!(now, 100);
delay.reset(now + ms(110));
delay.await;
assert_elapsed!(now... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | e2230f3392901e2bfb4b26fdf0d4977ec6c8545c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2230f3392901e2bfb4b26fdf0d4977ec6c8545c/tokio/tests/time_delay.rs | 121 | 176 |
tokio-rs/tokio:tokio/tests/time_delay.rs:5 | #[should_panic]
#[tokio::test]
async fn exactly_max() {
// TODO: this should not panic but `time::ms()` is acting up
time::delay_for(ms(MAX_DURATION)).await;
}
#[tokio::test]
async fn no_out_of_bounds_close_to_max() {
time::pause();
time::delay_for(ms(MAX_DURATION - 1)).await;
}
fn ms(n: u64) -> Durat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | e2230f3392901e2bfb4b26fdf0d4977ec6c8545c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2230f3392901e2bfb4b26fdf0d4977ec6c8545c/tokio/tests/time_delay.rs | 161 | 176 |
tokio-rs/tokio:tokio/tests/time_delay.rs:4 | assert_elapsed!(now, 80);
}
#[tokio::test]
async fn reset_future_delay_after_fire() {
time::pause();
let now = Instant::now();
let mut delay = time::delay_until(now + ms(100));
(&mut delay).await;
assert_elapsed!(now, 100);
delay.reset(now + ms(110));
delay.await;
assert_elapsed!(now... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay.rs | MIT | f0006006ed9938115011c42f26cff16842eb534f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/tests/time_delay.rs | 121 | 160 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:1 | #![allow(clippy::blacklisted_name)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, sleep, DelayQueue, Duration, Instant};
use tokio_test::{assert_ok, assert_pending, assert_ready, task};
macro_rules! poll {
($queue:ident) => {
$queue.enter(|cx, mut queue| queue.poll_expired(c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:2 | time::pause();
let mut queue = task::spawn(DelayQueue::new());
let _k = queue.insert_at("1", Instant::now());
let _k = queue.insert_at("2", Instant::now());
let _k = queue.insert_at("3", Instant::now());
sleep(ms(1)).await;
let mut res = vec![];
while res.len() < 3 {
let entry =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:3 | sleep(ms(5)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue));
assert_eq!(*entry.get_ref(), "foo");
let entry = assert_ready!(poll!(queue));
assert!(entry.is_none());
}
#[tokio::test]
async fn multi_delay_at_start() {
time::pause();
let long = 262_144 + 9 * 4... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:5 | time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let key = queue.insert_at("foo", now + ms(5));
assert_pending!(poll!(queue));
sleep(ms(1)).await;
queue.reset_at(&key, now + ms(10));
assert_pending!(poll!(queue));
sleep(ms(7)).await;
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:6 | let key = queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
sleep(ms(3)).await;
queue.reset_at(&key, now + ms(5));
sleep(ms(20)).await;
assert!(queue.is_woken());
}
// Reproduces tokio-rs/tokio#849.
#[tokio::test]
async fn reset_twice() {
time::pause();
let mut queu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:7 | #[tokio::test]
async fn remove_expired_item() {
time::pause();
let mut queue = DelayQueue::new();
let now = Instant::now();
sleep(ms(10)).await;
let key = queue.insert_at("foo", now);
let entry = queue.remove(&key);
assert_eq!(entry.into_inner(), "foo");
}
#[tokio::test]
async fn expir... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:8 | }
#[tokio::test]
async fn multi_reset() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
let two = queue.insert_at("two", now + ms(250));
assert_pending!(poll!(queue));
queue.reset_at(&one, now +... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:9 | async fn expire_first_key_when_reset_to_expire_earlier() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
queue.insert_at("two", now + ms(250));
assert_pending!(poll!(queue));
queue.reset_at(&one,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:10 | let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn reset_first_expiring_item_to_expire_later() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:11 | sleep(ms(99)).await;
assert!(!queue.is_woken());
sleep(ms(1)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn insert_after_ready_poll() {
time::pause();
let mut queue = task::spawn(DelayQueue... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:12 | assert_eq!("1", res[0]);
assert_eq!("2", res[1]);
assert_eq!("3", res[2]);
}
#[tokio::test]
async fn reset_later_after_slot_starts() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let foo = queue.insert_at("foo", now + ms(100));
assert_pending... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:13 | assert_eq!(entry, "foo");
}
#[tokio::test]
async fn reset_inserted_expired() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let key = queue.insert_at("foo", now - ms(100));
// this causes the panic described in #2473
queue.reset_at(&key, now + ms(10... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/time_delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:1 | #![allow(clippy::blacklisted_name)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, delay_for, DelayQueue, Duration, Instant};
use tokio_test::{assert_ok, assert_pending, assert_ready, task};
macro_rules! poll {
($queue:ident) => {
$queue.enter(|cx, mut queue| queue.poll_expir... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:2 | time::pause();
let mut queue = task::spawn(DelayQueue::new());
let _k = queue.insert_at("1", Instant::now());
let _k = queue.insert_at("2", Instant::now());
let _k = queue.insert_at("3", Instant::now());
delay_for(ms(1)).await;
let mut res = vec![];
while res.len() < 3 {
let ent... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:3 | delay_for(ms(5)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue));
assert_eq!(*entry.get_ref(), "foo");
let entry = assert_ready!(poll!(queue));
assert!(entry.is_none());
}
#[tokio::test]
async fn multi_delay_at_start() {
time::pause();
let long = 262_144 + 9... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:4 | assert_pending!(poll!(queue));
}
}
}
#[tokio::test]
async fn insert_in_past_fires_immediately() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
delay_for(ms(10)).await;
queue.insert_at("foo", now);
assert_ready!(poll!(queue));
}
#[toki... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:5 | time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let key = queue.insert_at("foo", now + ms(5));
assert_pending!(poll!(queue));
delay_for(ms(1)).await;
queue.reset_at(&key, now + ms(10));
assert_pending!(poll!(queue));
delay_for(ms(7)).await;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:6 | let key = queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
delay_for(ms(3)).await;
queue.reset_at(&key, now + ms(5));
delay_for(ms(20)).await;
assert!(queue.is_woken());
}
// Reproduces tokio-rs/tokio#849.
#[tokio::test]
async fn reset_twice() {
time::pause();
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:7 | #[tokio::test]
async fn remove_expired_item() {
time::pause();
let mut queue = DelayQueue::new();
let now = Instant::now();
delay_for(ms(10)).await;
let key = queue.insert_at("foo", now);
let entry = queue.remove(&key);
assert_eq!(entry.into_inner(), "foo");
}
#[tokio::test]
async fn e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:8 | }
#[tokio::test]
async fn multi_reset() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
let two = queue.insert_at("two", now + ms(250));
assert_pending!(poll!(queue));
queue.reset_at(&one, now +... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:9 | async fn expire_first_key_when_reset_to_expire_earlier() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
queue.insert_at("two", now + ms(250));
assert_pending!(poll!(queue));
queue.reset_at(&one,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:10 | let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn reset_first_expiring_item_to_expire_later() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:11 | delay_for(ms(99)).await;
assert!(!queue.is_woken());
delay_for(ms(1)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn insert_after_ready_poll() {
time::pause();
let mut queue = task::spawn(De... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:12 | assert_eq!("1", res[0]);
assert_eq!("2", res[1]);
assert_eq!("3", res[2]);
}
#[tokio::test]
async fn reset_later_after_slot_starts() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let foo = queue.insert_at("foo", now + ms(100));
assert_pending... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:13 | assert_eq!(entry, "foo");
}
#[tokio::test]
async fn reset_inserted_expired() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let key = queue.insert_at("foo", now - ms(100));
// this causes the panic described in #2473
queue.reset_at(&key, now + ms(10... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:14 | // At this point the queue hasn't been polled, so `elapsed` on the wheel
// for the queue is still at 0 and hence the 1ms resolution slots cover
// [0-64). Resetting the time on the entry to 120 causes it to get put in
// the [64-128) slot. As the queue knows that the first entry is within
// that slo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7f29acd964dfca9c9e90a87af607a7897eb8ea67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f29acd964dfca9c9e90a87af607a7897eb8ea67/tokio/tests/time_delay_queue.rs | 521 | 567 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:12 | assert_eq!("1", res[0]);
assert_eq!("2", res[1]);
assert_eq!("3", res[2]);
}
#[tokio::test]
async fn reset_later_after_slot_starts() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let foo = queue.insert_at("foo", now + ms(100));
assert_pending... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 9264b837d897dcdf974703a6739132b995e669bc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9264b837d897dcdf974703a6739132b995e669bc/tokio/tests/time_delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:13 | assert_eq!(entry, "foo");
}
#[tokio::test]
async fn reset_earlier_after_slot_starts() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let foo = queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
delay_for(ms(80)).await;
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 9264b837d897dcdf974703a6739132b995e669bc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9264b837d897dcdf974703a6739132b995e669bc/tokio/tests/time_delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:14 | #[tokio::test]
async fn insert_in_past_after_poll_fires_immediately() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
delay_for(ms(80)).await;
assert!(!queue.is_woken());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 9264b837d897dcdf974703a6739132b995e669bc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9264b837d897dcdf974703a6739132b995e669bc/tokio/tests/time_delay_queue.rs | 521 | 546 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, delay_for, DelayQueue, Duration, Instant};
use tokio_test::{assert_ok, assert_pending, assert_ready, task};
macro_rules! poll {
($queue:ident) => {
$queue.enter(|cx, mut queue| queue.poll_expired(cx))
};
}
macro_rules! asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:2 | let mut queue = task::spawn(DelayQueue::new());
let _k = queue.insert_at("1", Instant::now());
let _k = queue.insert_at("2", Instant::now());
let _k = queue.insert_at("3", Instant::now());
delay_for(ms(1)).await;
let mut res = vec![];
while res.len() < 3 {
let entry = assert_ready_ok... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:3 | assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue));
assert_eq!(*entry.get_ref(), "foo");
let entry = assert_ready!(poll!(queue));
assert!(entry.is_none());
}
#[tokio::test]
async fn multi_delay_at_start() {
time::pause();
let long = 262_144 + 9 * 4096;
let delays = &[1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:4 | }
}
}
#[tokio::test]
async fn insert_in_past_fires_immediately() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
delay_for(ms(10)).await;
queue.insert_at("foo", now);
assert_ready!(poll!(queue));
}
#[tokio::test]
async fn remove_entry() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:5 | let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let key = queue.insert_at("foo", now + ms(5));
assert_pending!(poll!(queue));
delay_for(ms(1)).await;
queue.reset_at(&key, now + ms(10));
assert_pending!(poll!(queue));
delay_for(ms(7)).await;
assert!(!queue.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:6 | let key = queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
delay_for(ms(3)).await;
queue.reset_at(&key, now + ms(5));
delay_for(ms(20)).await;
assert!(queue.is_woken());
}
// Reproduces tokio-rs/tokio#849.
#[tokio::test]
async fn reset_twice() {
time::pause();
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:7 | async fn remove_expired_item() {
time::pause();
let mut queue = DelayQueue::new();
let now = Instant::now();
delay_for(ms(10)).await;
let key = queue.insert_at("foo", now);
let entry = queue.remove(&key);
assert_eq!(entry.into_inner(), "foo");
}
#[tokio::test]
async fn expires_before_l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:8 | #[tokio::test]
async fn multi_reset() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
let two = queue.insert_at("two", now + ms(250));
assert_pending!(poll!(queue));
queue.reset_at(&one, now + ms... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:9 | time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
queue.insert_at("two", now + ms(250));
assert_pending!(poll!(queue));
queue.reset_at(&one, now + ms(100));
delay_for(ms(100)).await;
assert!(qu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:11 | delay_for(ms(99)).await;
assert!(!queue.is_woken());
delay_for(ms(1)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn insert_after_ready_poll() {
time::pause();
let mut queue = task::spawn(De... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:12 | assert_eq!("1", res[0]);
assert_eq!("2", res[1]);
assert_eq!("3", res[2]);
}
#[tokio::test]
async fn reset_later_after_slot_starts() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let foo = queue.insert_at("foo", now + ms(100));
assert_pending... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:13 | }
#[tokio::test]
async fn reset_earlier_after_slot_starts() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let foo = queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
delay_for(ms(80)).await;
assert!(!queue.is_woken());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:14 | async fn insert_in_past_after_poll_fires_immediately() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
queue.insert_at("foo", now + ms(200));
assert_pending!(poll!(queue));
delay_for(ms(80)).await;
assert!(!queue.is_woken());
queue.insert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 947045b9445f15fb9314ba0892efa2251076ae73 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/947045b9445f15fb9314ba0892efa2251076ae73/tokio/tests/time_delay_queue.rs | 521 | 545 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:11 | delay_for(ms(99)).await;
assert!(!queue.is_woken());
delay_for(ms(1)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn insert_after_ready_poll() {
time::pause();
let mut queue = task::spawn(De... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 6cf1a5b6b8686e5bde107d072d77199aaefcb2ec | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6cf1a5b6b8686e5bde107d072d77199aaefcb2ec/tokio/tests/time_delay_queue.rs | 401 | 448 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:10 | let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn reset_first_expiring_item_to_expire_later() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/tests/time_delay_queue.rs | 361 | 415 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:11 | delay_for(ms(99)).await;
assert!(!queue.is_woken());
delay_for(ms(1)).await;
assert!(queue.is_woken());
let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
fn ms(n: u64) -> Duration {
Duration::from_millis(n)
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | 7207bf355e2b6418bb0d757859a5cdcdedf32530 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207bf355e2b6418bb0d757859a5cdcdedf32530/tokio/tests/time_delay_queue.rs | 401 | 415 |
tokio-rs/tokio:tokio/tests/time_delay_queue.rs:10 | let entry = assert_ready_ok!(poll!(queue)).into_inner();
assert_eq!(entry, "two");
}
#[tokio::test]
async fn reset_first_expiring_item_to_expire_later() {
time::pause();
let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();
let one = queue.insert_at("one", now + ms(200));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_delay_queue.rs | MIT | f0006006ed9938115011c42f26cff16842eb534f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/tests/time_delay_queue.rs | 361 | 389 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::{Stream, StreamExt};
use tokio::time::{self, Duration, Instant, Interval, MissedTickBehavior};
use tokio_test::{assert_pending, assert_ready, assert_ready_eq, task};
// Takes the `Interval` task, `sta... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | // Ready(s + 6p)
#[tokio::test(start_paused = true)]
async fn burst() {
let start = Instant::now();
// This is necessary because the timer is only so granular, and in order for
// all our ticks to resolve, the time needs to be 1ms ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_interval.rs:3 | // Ready(s) | | Ready(s + 2p) | | | |
// Pending | Pending | | |
// Ready(s + p) Ready(s + 2p + d) | |
// ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_interval.rs:4 | time::advance(ms(300)).await;
// Again, we add one.
check_interval_poll!(i, start, 1551);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1851);
}
// Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 |
// Actual ticks: | work -----| delay ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_interval.rs:5 | time::advance(ms(250)).await;
check_interval_poll!(i, start, 1200);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1500);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1800);
}
#[tokio::test(start_paused = true)]
async fn reset() {
let start = Instant::now();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_interval.rs:6 | check_interval_poll!(i, start, 701);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1001);
}
#[tokio::test(start_paused = true)]
async fn reset_immediately() {
let start = Instant::now();
// This is necessary because the timer is only so granular, and in order for
// all our ticks t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_interval.rs:7 | #[tokio::test(start_paused = true)]
async fn reset_after() {
let start = Instant::now();
// This is necessary because the timer is only so granular, and in order for
// all our ticks to resolve, the time needs to be 1ms ahead of what we
// expect, so that the runtime will see that it is time to resolve... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_interval.rs:8 | // This is necessary because the timer is only so granular, and in order for
// all our ticks to resolve, the time needs to be 1ms ahead of what we
// expect, so that the runtime will see that it is time to resolve the timer
time::advance(ms(1)).await;
let mut i = task::spawn(time::interval_at(start, m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/time_interval.rs:9 | time::advance(ms(1)).await;
let mut i = task::spawn(time::interval_at(start, ms(300)));
check_interval_poll!(i, start, 0);
time::advance(ms(100)).await;
check_interval_poll!(i, start);
time::advance(ms(200)).await;
check_interval_poll!(i, start, 300);
time::advance(ms(100)).await;
c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/time_interval.rs:10 | }
/// Helper struct to test the [tokio::time::Interval::poll_tick()] method.
///
/// `poll_tick()` should register the waker in the context only if it returns
/// `Poll::Pending`, not when returning `Poll::Ready`. This struct contains an
/// interval timer and counts up on every tick when used as stream. When the
/// ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/time_interval.rs:11 | }
}
}
}
}
#[tokio::test(start_paused = true)]
async fn stream_with_interval_poll_tick_self_waking() {
let stream = IntervalStreamer {
counter: 0,
timer: tokio::time::interval(tokio::time::Duration::from_millis(10)),
wake_on_pending: true,
};
let (res_tx, mut... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/time_interval.rs:12 | let stream = IntervalStreamer {
counter: 0,
timer: tokio::time::interval(tokio::time::Duration::from_millis(10)),
wake_on_pending: false,
};
let (res_tx, mut res_rx) = tokio::sync::mpsc::channel(12);
// Wrap task in timeout so that it will finish eventually even if the stream
/... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/time_interval.rs | 441 | 477 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::{Stream, StreamExt};
use tokio::time::{self, Duration, Instant, Interval, MissedTickBehavior};
use tokio_test::{assert_pending, assert_ready_eq, task};
// Takes the `Interval` task, `start` variable, ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 593dbf55d1165df9d27f81b1214eecacbb7f94dc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/593dbf55d1165df9d27f81b1214eecacbb7f94dc/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:12 | let stream = IntervalStreamer {
counter: 0,
timer: tokio::time::interval(tokio::time::Duration::from_millis(10)),
wake_on_pending: false,
};
let (res_tx, mut res_rx) = tokio::sync::mpsc::channel(12);
// Wrap task in timeout so that it will finish eventually even if the stream
/... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 593dbf55d1165df9d27f81b1214eecacbb7f94dc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/593dbf55d1165df9d27f81b1214eecacbb7f94dc/tokio/tests/time_interval.rs | 441 | 471 |
tokio-rs/tokio:tokio/tests/time_interval.rs:5 | time::advance(ms(250)).await;
check_interval_poll!(i, start, 1200);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1500);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1800);
}
#[tokio::test(start_paused = true)]
async fn reset() {
let start = Instant::now();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | dbda2045f18713f752902226d7bad24037b5788b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbda2045f18713f752902226d7bad24037b5788b/tokio/tests/time_interval.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_interval.rs:6 | check_interval_poll!(i, start, 701);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1001);
}
#[tokio::test(start_paused = true)]
async fn reset_immediatelly() {
let start = Instant::now();
// This is necessary because the timer is only so granular, and in order for
// all our ticks ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | dbda2045f18713f752902226d7bad24037b5788b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbda2045f18713f752902226d7bad24037b5788b/tokio/tests/time_interval.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_interval.rs:5 | time::advance(ms(250)).await;
check_interval_poll!(i, start, 1200);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1500);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1800);
}
#[tokio::test(start_paused = true)]
async fn reset() {
let start = Instant::now();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 68b02db1543880cb95ceccc39f453f8dd2223f04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68b02db1543880cb95ceccc39f453f8dd2223f04/tokio/tests/time_interval.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/time_interval.rs:6 | check_interval_poll!(i, start, 701);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1001);
}
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_interval.rs | MIT | 68b02db1543880cb95ceccc39f453f8dd2223f04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68b02db1543880cb95ceccc39f453f8dd2223f04/tokio/tests/time_interval.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/time_interval.rs:7 | match this.timer.poll_tick(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(_) => {
this.counter += 1;
if this.counter % 4 == 0 {
Poll::Ready(Some(this.counter))
} else {
if this.wake_on_pending {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 68b02db1543880cb95ceccc39f453f8dd2223f04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68b02db1543880cb95ceccc39f453f8dd2223f04/tokio/tests/time_interval.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/time_interval.rs:8 | let mut items = Vec::with_capacity(3);
while let Some(result) = res_rx.recv().await {
items.push(result);
}
// We expect the stream to yield normally and thus three items.
assert_eq!(items, vec![4, 8, 12]);
}
#[tokio::test(start_paused = true)]
async fn stream_with_interval_poll_tick_no_waking... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 68b02db1543880cb95ceccc39f453f8dd2223f04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68b02db1543880cb95ceccc39f453f8dd2223f04/tokio/tests/time_interval.rs | 281 | 323 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant, MissedTickBehavior};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::task::Poll;
// Takes the `Interval` task, `start` variable, and optional time deltas
// For each time delta, it polls the `Interval` a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 347c0cdaba27eea8e54b034db4195fa71652c5a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/347c0cdaba27eea8e54b034db4195fa71652c5a1/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | async fn burst() {
let start = Instant::now();
// This is necessary because the timer is only so granular, and in order for
// all our ticks to resolve, the time needs to be 1ms ahead of what we
// expect, so that the runtime will see that it is time to resolve the timer
time::advance(ms(1)).await;... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 347c0cdaba27eea8e54b034db4195fa71652c5a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/347c0cdaba27eea8e54b034db4195fa71652c5a1/tokio/tests/time_interval.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/time_interval.rs:3 | // Ready(s + p) Ready(s + 2p + d) | |
// Ready(s + 3p + d) |
// Ready(s + 4p + d)
#[tokio::test(start_paused = true)]... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 347c0cdaba27eea8e54b034db4195fa71652c5a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/347c0cdaba27eea8e54b034db4195fa71652c5a1/tokio/tests/time_interval.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/time_interval.rs:4 | // Again, we add one.
check_interval_poll!(i, start, 1551);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1851);
}
// Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 |
// Actual ticks: | work -----| delay | work ---| work -----| wo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 347c0cdaba27eea8e54b034db4195fa71652c5a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/347c0cdaba27eea8e54b034db4195fa71652c5a1/tokio/tests/time_interval.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/time_interval.rs:5 | time::advance(ms(300)).await;
check_interval_poll!(i, start, 1500);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1800);
}
#[tokio::test(start_paused = true)]
async fn reset() {
let start = Instant::now();
// This is necessary because the timer is only so granular, and in order for... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 347c0cdaba27eea8e54b034db4195fa71652c5a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/347c0cdaba27eea8e54b034db4195fa71652c5a1/tokio/tests/time_interval.rs | 161 | 211 |
tokio-rs/tokio:tokio/tests/time_interval.rs:6 | time::advance(ms(300)).await;
check_interval_poll!(i, start, 1001);
}
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_interval.rs | MIT | 347c0cdaba27eea8e54b034db4195fa71652c5a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/347c0cdaba27eea8e54b034db4195fa71652c5a1/tokio/tests/time_interval.rs | 201 | 211 |
tokio-rs/tokio:tokio/tests/time_interval.rs:4 | // Again, we add one.
check_interval_poll!(i, start, 1551);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1851);
}
// Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 |
// Actual ticks: | work -----| delay | work ---| work -----| wo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | e979ad7f2d101b7969d03a4af13dd9a132ee1ec5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e979ad7f2d101b7969d03a4af13dd9a132ee1ec5/tokio/tests/time_interval.rs | 121 | 175 |
tokio-rs/tokio:tokio/tests/time_interval.rs:5 | time::advance(ms(300)).await;
check_interval_poll!(i, start, 1500);
time::advance(ms(300)).await;
check_interval_poll!(i, start, 1800);
}
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 {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | e979ad7f2d101b7969d03a4af13dd9a132ee1ec5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e979ad7f2d101b7969d03a4af13dd9a132ee1ec5/tokio/tests/time_interval.rs | 161 | 175 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::future::Future;
use std::task::Poll;
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = time::interval_at(Instant::now(), ms(0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/tests/time_interval.rs | 1 | 58 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::future::Future;
use std::task::Poll;
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = time::interval_at(Instant::now(), ms(0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | time::advance(ms(500)).await;
assert_ready_eq!(poll_next(&mut i), start + ms(900));
assert_ready_eq!(poll_next(&mut i), start + ms(1200));
assert_pending!(poll_next(&mut i));
}
#[tokio::test]
async fn usage_stream() {
use tokio::stream::StreamExt;
let start = Instant::now();
let interval = tim... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | ae67851f11b7cc1f577de8ce21767ce3e2c7aff9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ae67851f11b7cc1f577de8ce21767ce3e2c7aff9/tokio/tests/time_interval.rs | 41 | 73 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::future::Future;
use std::task::Poll;
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = time::interval_at(Instant::now(), ms(0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 7ec6d88b21ea3e5531176f526a51dae0a4513025 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ec6d88b21ea3e5531176f526a51dae0a4513025/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | time::advance(ms(500)).await;
assert_ready_eq!(poll_next(&mut i), start + ms(900));
assert_ready_eq!(poll_next(&mut i), start + ms(1200));
assert_pending!(poll_next(&mut i));
}
#[tokio::test]
async fn usage_stream() {
use tokio::stream::StreamExt;
let start = Instant::now();
let mut interval =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 7ec6d88b21ea3e5531176f526a51dae0a4513025 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ec6d88b21ea3e5531176f526a51dae0a4513025/tokio/tests/time_interval.rs | 41 | 72 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::task::Poll;
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = time::interval_at(Instant::now(), ms(0));
}
#[tokio::test]
asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 4c645866ef4ea5b0ef8c7852281a09b2f96d969b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4c645866ef4ea5b0ef8c7852281a09b2f96d969b/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | assert_ready_eq!(poll_next(&mut i), start + ms(900));
assert_ready_eq!(poll_next(&mut i), start + ms(1200));
assert_pending!(poll_next(&mut i));
}
#[tokio::test]
async fn usage_stream() {
use tokio::stream::StreamExt;
let start = Instant::now();
let mut interval = time::interval(ms(10));
for ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 4c645866ef4ea5b0ef8c7852281a09b2f96d969b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4c645866ef4ea5b0ef8c7852281a09b2f96d969b/tokio/tests/time_interval.rs | 41 | 66 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::task::Poll;
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = time::interval_at(Instant::now(), ms(0));
}
#[tokio::test]
asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | assert_ready_eq!(poll_next(&mut i), start + ms(900));
assert_ready_eq!(poll_next(&mut i), start + ms(1200));
assert_pending!(poll_next(&mut i));
}
#[tokio::test]
async fn usage_stream() {
use futures::StreamExt;
let start = Instant::now();
let mut interval = time::interval(ms(10));
for _ in 0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/time_interval.rs | 41 | 66 |
tokio-rs/tokio:tokio/tests/time_interval.rs:1 | #![warn(rust_2018_idioms)]
use tokio::time::{self, Duration, Instant};
use tokio_test::{assert_pending, assert_ready_eq, task};
use std::task::Poll;
#[tokio::test]
#[should_panic]
async fn interval_zero_duration() {
let _ = time::interval_at(Instant::now(), ms(0));
}
#[tokio::test]
async fn usage() {
time::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/tests/time_interval.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/time_interval.rs:2 | assert_ready_eq!(poll_next(&mut i), start + ms(1200));
assert_pending!(poll_next(&mut i));
}
#[tokio::test]
async fn usage_stream() {
use futures::StreamExt;
let start = Instant::now();
let mut interval = time::interval(ms(10));
for _ in 0..3 {
interval.next().await.unwrap();
}
a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/time_interval.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/tests/time_interval.rs | 41 | 65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.