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/timer.rs:1
#![warn(rust_2018_idioms)] #![feature(async_await)] #![cfg(feature = "default")] use tokio::prelude::*; use tokio::timer::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[test] fn timer_with_threaded_runtime() { use tokio::runtime::Runtime; let rt = Runtime::new().unwrap(); let (tx, rx) = m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
73102760cfe1632b6b8073dfa5a506c0e69e4b5e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/73102760cfe1632b6b8073dfa5a506c0e69e4b5e/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:2
Delay::new(when).await; assert!(Instant::now() >= when); tx.send(()).unwrap(); }); rt.run().unwrap(); rx.recv().unwrap(); } #[tokio::test] async fn starving() { use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; struct Starve(Delay, u64); imp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
73102760cfe1632b6b8073dfa5a506c0e69e4b5e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/73102760cfe1632b6b8073dfa5a506c0e69e4b5e/tokio/tests/timer.rs
41
95
tokio-rs/tokio:tokio/tests/timer.rs:1
#![deny(warnings, rust_2018_idioms)] #![feature(async_await)] #![cfg(feature = "default")] use tokio::prelude::*; use tokio::timer::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[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/timer.rs
MIT
962521f449dead58eb37eb46857bc6c52ee3a8da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/962521f449dead58eb37eb46857bc6c52ee3a8da/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:1
#![deny(warnings, rust_2018_idioms)] #![feature(async_await)] use tokio; use tokio::prelude::*; // use tokio::sync::mpsc; use tokio::timer::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[test] fn timer_with_threaded_runtime() { use tokio::runtime::Runtime; let rt = Runtime::new().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
47e2ff48d9f1daac7dba9f136b24eed64c87cf40
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47e2ff48d9f1daac7dba9f136b24eed64c87cf40/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:2
let when = Instant::now() + Duration::from_millis(100); Delay::new(when).await; assert!(Instant::now() >= when); tx.send(()).unwrap(); }); rt.run().unwrap(); rx.recv().unwrap(); } #[tokio::test] async fn starving() { use std::future::Future; use std::pin::Pin; use std...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
47e2ff48d9f1daac7dba9f136b24eed64c87cf40
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47e2ff48d9f1daac7dba9f136b24eed64c87cf40/tokio/tests/timer.rs
41
96
tokio-rs/tokio:tokio/tests/timer.rs:3
assert!(Instant::now() >= when); } #[tokio::test] async fn timeout() { use tokio::sync::oneshot; let (_tx, rx) = oneshot::channel::<()>(); let now = Instant::now(); let dur = Duration::from_millis(20); let res = rx.timeout(dur).await; assert!(res.is_err()); assert!(Instant::now() >= now ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
47e2ff48d9f1daac7dba9f136b24eed64c87cf40
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47e2ff48d9f1daac7dba9f136b24eed64c87cf40/tokio/tests/timer.rs
81
96
tokio-rs/tokio:tokio/tests/timer.rs:1
#![deny(warnings, rust_2018_idioms)] #![feature(async_await)] use tokio; use tokio::prelude::*; // use tokio::sync::mpsc; use tokio::timer::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[test] fn timer_with_threaded_runtime() { use tokio::runtime::Runtime; let rt = Runtime::new().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
bd3f3270dbf632a7e23e82dd93605db1fe050ee9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd3f3270dbf632a7e23e82dd93605db1fe050ee9/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:2
rt.spawn(async move { let when = Instant::now() + Duration::from_millis(100); Delay::new(when).await; assert!(Instant::now() >= when); tx.send(()).unwrap(); }); rt.run().unwrap(); rx.recv().unwrap(); } #[tokio::test] async fn starving() { use std::future::Future; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
bd3f3270dbf632a7e23e82dd93605db1fe050ee9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd3f3270dbf632a7e23e82dd93605db1fe050ee9/tokio/tests/timer.rs
41
97
tokio-rs/tokio:tokio/tests/timer.rs:3
starve.await; assert!(Instant::now() >= when); } #[tokio::test] async fn timeout() { use tokio::sync::oneshot; let (_tx, rx) = oneshot::channel::<()>(); let now = Instant::now(); let dur = Duration::from_millis(20); let res = rx.timeout(dur).await; assert!(res.is_err()); assert!(Inst...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
bd3f3270dbf632a7e23e82dd93605db1fe050ee9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd3f3270dbf632a7e23e82dd93605db1fe050ee9/tokio/tests/timer.rs
81
97
tokio-rs/tokio:tokio/tests/timer.rs:1
#![deny(warnings, rust_2018_idioms)] #![feature(async_await)] use tokio; use tokio::prelude::*; // use tokio::sync::mpsc; use tokio::timer::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[test] fn timer_with_threaded_runtime() { use tokio::runtime::Runtime; let mut rt = Runtime::new().unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
70eca184f0f52dd2d634b750bba698da9418ee5f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/70eca184f0f52dd2d634b750bba698da9418ee5f/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:1
#![cfg(feature = "broken")] #![deny(warnings, rust_2018_idioms)] use env_logger; use std::sync::mpsc; use std::time::{Duration, Instant}; use tokio; use tokio::prelude::*; use tokio::timer::*; #[test] fn timer_with_runtime() { let _ = env_logger::try_init(); let when = Instant::now() + Duration::from_millis(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
29e417c257c62ae95cfa73f6b56825b3f833dde8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:2
type Error = (); fn poll(&mut self) -> Poll<Self::Item, ()> { if self.0.poll().unwrap().is_ready() { return Ok(self.1.into()); } self.1 += 1; task::current().notify(); Ok(Async::NotReady) } } let when = Instant::now...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
29e417c257c62ae95cfa73f6b56825b3f833dde8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/timer.rs
41
100
tokio-rs/tokio:tokio/tests/timer.rs:3
#[allow(deprecated)] tokio::run({ future::empty::<(), ()>().deadline(when).then(move |res| { assert!(res.is_err()); tx.send(()).unwrap(); Ok(()) }) }); rx.recv().unwrap(); } #[test] fn timeout() { use futures::future; let _ = env_logger::try_ini...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
29e417c257c62ae95cfa73f6b56825b3f833dde8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/timer.rs
81
112
tokio-rs/tokio:tokio/tests/timer.rs:1
#![deny(warnings, rust_2018_idioms)] use env_logger; use std::sync::mpsc; use std::time::{Duration, Instant}; use tokio; use tokio::prelude::*; use tokio::timer::*; #[test] fn timer_with_runtime() { let _ = env_logger::try_init(); let when = Instant::now() + Duration::from_millis(100); let (tx, rx) = mps...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/timer.rs
1
60
tokio-rs/tokio:tokio/tests/timer.rs:2
fn poll(&mut self) -> Poll<Self::Item, ()> { if self.0.poll().unwrap().is_ready() { return Ok(self.1.into()); } self.1 += 1; task::current().notify(); Ok(Async::NotReady) } } let when = Instant::now() + Duration::from_millis...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/timer.rs
41
100
tokio-rs/tokio:tokio/tests/timer.rs:3
tokio::run({ future::empty::<(), ()>().deadline(when).then(move |res| { assert!(res.is_err()); tx.send(()).unwrap(); Ok(()) }) }); rx.recv().unwrap(); } #[test] fn timeout() { use futures::future; let _ = env_logger::try_init(); let (tx, rx) = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer.rs
MIT
cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/timer.rs
81
111
tokio-rs/tokio:tokio/tests/timer_clock.rs:1
#![warn(rust_2018_idioms)] use tokio::time::clock; use tokio::time::clock::*; use std::time::Instant; struct ConstNow(Instant); impl Now for ConstNow { fn now(&self) -> Instant { self.0 } } #[test] fn default_clock() { let a = Instant::now(); let b = clock::now(); let c = Clock::new().n...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_clock.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_clock.rs
1
48
tokio-rs/tokio:tokio/tests/timer_delay.rs:1
#![warn(rust_2018_idioms)] use tokio::time::delay; use tokio::time::timer::Handle; use tokio_test::task; use tokio_test::{assert_pending, assert_ready, clock}; use std::time::{Duration, Instant}; #[test] fn immediate_delay() { clock::mock(|clock| { // Create `Delay` that elapsed immediately. let ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
1
60
tokio-rs/tokio:tokio/tests/timer_delay.rs:2
}); } } #[test] fn sub_ms_delayed_delay() { clock::mock(|clock| { for _ in 0..5 { let deadline = clock.now() + Duration::from_millis(1) + Duration::new(0, 1); let mut fut = task::spawn(delay(deadline)); assert_pending!(fut.poll()); clock.turn(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
41
100
tokio-rs/tokio:tokio/tests/timer_delay.rs:3
assert_ready!(fut.poll()); }); } #[test] fn timer_wrapping_with_higher_levels() { clock::mock(|clock| { // Set delay to hit level 1 let mut s1 = task::spawn(delay(clock.now() + ms(64))); assert_pending!(s1.poll()); // Turn a bit clock.turn_for(ms(5)); // Set ti...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
81
140
tokio-rs/tokio:tokio/tests/timer_delay.rs:4
// because the timer must observe it. assert_ready!(fut.poll()); // Turn the timer, it runs for the elapsed time clock.turn_for(ms(1000)); // The time has not advanced. The `turn` completed immediately. assert_eq!(clock.advanced(), ms(1000)); }); } #[test] fn delayed_delay...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
121
180
tokio-rs/tokio:tokio/tests/timer_delay.rs:5
assert_pending!(fut.poll()); // Turn the timer with a smaller timeout than the cascade. clock.turn_for(ms(100)); assert_eq!(clock.advanced(), ms(100)); assert_pending!(fut.poll()); // Turn the timer, this will wake up to cascade the timer down. clock.turn_for(ms(1000))...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
161
220
tokio-rs/tokio:tokio/tests/timer_delay.rs:6
assert_pending!(fut.poll()); clock.turn_for(ms(1000)); assert_eq!(clock.advanced(), ms(500)); // The delay has elapsed assert_ready!(fut.poll()); }); } #[test] fn concurrently_set_two_timers_second_one_shorter() { clock::mock(|clock| { let mut fut1 = task::spawn(delay(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
201
260
tokio-rs/tokio:tokio/tests/timer_delay.rs:7
assert_ready!(fut1.poll()); }) } #[test] fn short_delay() { clock::mock(|clock| { // Create a `Delay` that elapses in the future let mut fut = task::spawn(delay(clock.now() + ms(1))); // The delay has not elapsed. assert_pending!(fut.poll()); // Turn the timer, but not...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
241
300
tokio-rs/tokio:tokio/tests/timer_delay.rs:8
assert_eq!(clock.advanced(), ms(elapsed)); assert_pending!(fut.poll()); } clock.turn(); assert_eq!(clock.advanced(), ms(MIN_5)); // The delay has elapsed. assert_ready!(fut.poll()); }) } #[test] fn very_long_delay() { const MO_5: u64 = 5 * 30 * 24 * 60 * 6...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
281
340
tokio-rs/tokio:tokio/tests/timer_delay.rs:9
// The time has advanced to the point of the delay elapsing. assert_eq!(clock.advanced(), ms(MO_5)); // The delay has elapsed. assert_ready!(fut.poll()); }) } #[test] #[should_panic] fn greater_than_max() { const YR_5: u64 = 5 * 365 * 24 * 60 * 60 * 1000; clock::mock(|clock| { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
321
380
tokio-rs/tokio:tokio/tests/timer_delay.rs:10
assert_eq!(clock.advanced(), ms(500)); assert_ready!(fut1.poll()); assert_ready!(fut2.poll()); assert_ready!(fut3.poll()); }) } #[test] fn set_timeout_at_deadline_greater_than_max_timer() { const YR_1: u64 = 365 * 24 * 60 * 60 * 1000; const YR_5: u64 = 5 * YR_1; clock::mock(|c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
361
420
tokio-rs/tokio:tokio/tests/timer_delay.rs:11
assert_pending!(fut.poll()); clock.turn(); assert_eq!(clock.advanced(), ms(200)); assert_ready!(fut.poll()); }); } #[test] fn reset_past_delay_before_turn() { clock::mock(|clock| { let mut fut = task::spawn(delay(clock.now() + ms(100))); assert_pending!(fut.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
401
460
tokio-rs/tokio:tokio/tests/timer_delay.rs:12
clock.turn(); assert_eq!(clock.advanced(), ms(64)); assert_pending!(fut.poll()); clock.turn(); assert_eq!(clock.advanced(), ms(90)); assert_ready!(fut.poll()); }); } #[test] fn reset_future_delay_after_fire() { clock::mock(|clock| { let mut fut = task::spawn(d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
441
497
tokio-rs/tokio:tokio/tests/timer_delay.rs:13
let handle = Handle::default(); let now = Instant::now(); let mut fut = task::spawn(handle.delay(now + ms(1))); clock::mock_at(now, |clock| { assert_pending!(fut.poll()); clock.turn_for(ms(1)); assert_ready!(fut.poll()); }); } fn ms(n: u64) -> Duration { Duration::from_m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_delay.rs
481
497
tokio-rs/tokio:tokio/tests/timer_delay.rs:1
#![warn(rust_2018_idioms)] use tokio::timer::delay; use tokio::timer::timer::Handle; use tokio_test::task; use tokio_test::{assert_pending, assert_ready, clock}; use std::time::{Duration, Instant}; #[test] fn immediate_delay() { clock::mock(|clock| { // Create `Delay` that elapsed immediately. le...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_delay.rs
MIT
966ccd5d5306adf6b6c39721331c2a3c32be6fa8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/timer_delay.rs
1
60
tokio-rs/tokio:tokio/tests/timer_hammer.rs:1
#![warn(rust_2018_idioms)] #![cfg(broken)] use tokio::executor::park::{Park, Unpark, UnparkThread}; use tokio::runtime; use tokio::time::{Delay, Timer}; use rand::Rng; use std::cmp; use std::future::Future; use std::pin::Pin; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::SeqCst; use std::sync::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_hammer.rs
1
60
tokio-rs/tokio:tokio/tests/timer_hammer.rs:2
for _ in 0..THREADS { let handle = handle.clone(); let barrier = barrier.clone(); let done = done.clone(); thread::spawn(move || { let mut exec = rt(); let mut rng = rand::thread_rng(); barrier.wait(); for...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_hammer.rs
41
100
tokio-rs/tokio:tokio/tests/timer_hammer.rs:3
#[test] fn hammer_cancel() { const ITERS: usize = 5; const THREADS: usize = 4; const PER_THREAD: usize = 40; const MIN_DELAY: u64 = 1; const MAX_DELAY: u64 = 5_000; for _ in 0..ITERS { let mut timer = Timer::default(); let handle = timer.handle(); let barrier = Arc::new(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_hammer.rs
81
140
tokio-rs/tokio:tokio/tests/timer_hammer.rs:4
let now = Instant::now(); assert!(now >= deadline, "deadline greater by {:?}", deadline - now); }); } // Run the logic exec.run().unwrap(); if 1 == done.rem.fetch_sub(1, SeqCst) { done.unpar...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_hammer.rs
121
180
tokio-rs/tokio:tokio/tests/timer_hammer.rs:5
let handle = handle.clone(); let barrier = barrier.clone(); let done = done.clone(); thread::spawn(move || { let mut exec = rt(); let mut rng = rand::thread_rng(); barrier.wait(); for _ in 0..PER_THREAD { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_hammer.rs
161
220
tokio-rs/tokio:tokio/tests/timer_hammer.rs:6
if res.is_ready() { return Poll::Ready(self.b.take().unwrap()); } Poll::Pending } } let s = Select { a: Some(handle.delay(deadline1)), ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_hammer.rs
201
246
tokio-rs/tokio:tokio/tests/timer_hammer.rs:1
#![warn(rust_2018_idioms)] #![cfg(broken)] use tokio::executor::park::{Park, Unpark, UnparkThread}; use tokio::runtime; use tokio::timer::{Delay, Timer}; use rand::Rng; use std::cmp; use std::future::Future; use std::pin::Pin; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::SeqCst; use std::sync:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
d70c928d88dff9e3e8d673b8ee02bce131598550
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d70c928d88dff9e3e8d673b8ee02bce131598550/tokio/tests/timer_hammer.rs
1
60
tokio-rs/tokio:tokio/tests/timer_hammer.rs:1
#![warn(rust_2018_idioms)] use tokio::executor::current_thread::CurrentThread; use tokio::executor::park::{Park, Unpark, UnparkThread}; use tokio::timer::{Delay, Timer}; use rand::Rng; use std::cmp; use std::future::Future; use std::pin::Pin; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::SeqCst...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/tests/timer_hammer.rs
1
60
tokio-rs/tokio:tokio/tests/timer_hammer.rs:2
for _ in 0..THREADS { let handle = handle.clone(); let barrier = barrier.clone(); let done = done.clone(); thread::spawn(move || { let mut exec = CurrentThread::new(); let mut rng = rand::thread_rng(); barrier.wait(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/tests/timer_hammer.rs
41
100
tokio-rs/tokio:tokio/tests/timer_hammer.rs:3
fn hammer_cancel() { const ITERS: usize = 5; const THREADS: usize = 4; const PER_THREAD: usize = 40; const MIN_DELAY: u64 = 1; const MAX_DELAY: u64 = 5_000; for _ in 0..ITERS { let mut timer = Timer::default(); let handle = timer.handle(); let barrier = Arc::new(Barrier:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/tests/timer_hammer.rs
81
140
tokio-rs/tokio:tokio/tests/timer_hammer.rs:4
let now = Instant::now(); assert!(now >= deadline, "deadline greater by {:?}", deadline - now); }); } // Run the logic exec.run().unwrap(); if 1 == done.rem.fetch_sub(1, SeqCst) { done.unpar...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/tests/timer_hammer.rs
121
180
tokio-rs/tokio:tokio/tests/timer_hammer.rs:5
let barrier = barrier.clone(); let done = done.clone(); thread::spawn(move || { let mut exec = CurrentThread::new(); let mut rng = rand::thread_rng(); barrier.wait(); for _ in 0..PER_THREAD { let deadline1 = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/tests/timer_hammer.rs
161
220
tokio-rs/tokio:tokio/tests/timer_hammer.rs:6
return Poll::Ready(self.b.take().unwrap()); } Poll::Pending } } let s = Select { a: Some(handle.delay(deadline1)), b: Some(handle.delay(deadline2)), ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_hammer.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/tests/timer_hammer.rs
201
241
tokio-rs/tokio:tokio/tests/timer_interval.rs:1
#![warn(rust_2018_idioms)] use tokio::time::*; use tokio_test::task; use tokio_test::{assert_pending, assert_ready_eq, clock}; use std::time::Duration; #[test] #[should_panic] fn interval_zero_duration() { clock::mock(|clock| { let _ = Interval::new(clock.now(), ms(0)); }); } #[test] fn usage() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_interval.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_interval.rs
1
46
tokio-rs/tokio:tokio/tests/timer_interval.rs:1
#![warn(rust_2018_idioms)] use tokio::timer::*; use tokio_test::task; use tokio_test::{assert_pending, assert_ready_eq, clock}; use std::time::Duration; #[test] #[should_panic] fn interval_zero_duration() { clock::mock(|clock| { let _ = Interval::new(clock.now(), ms(0)); }); } #[test] fn usage() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_interval.rs
MIT
966ccd5d5306adf6b6c39721331c2a3c32be6fa8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/timer_interval.rs
1
46
tokio-rs/tokio:tokio/tests/timer_queue.rs:1
#![warn(rust_2018_idioms)] use tokio::time::*; use tokio_test::{assert_ok, assert_pending, assert_ready}; use tokio_test::{clock, task}; use std::time::Duration; macro_rules! poll { ($queue:ident) => { $queue.enter(|cx, mut queue| queue.poll_next(cx)) }; } macro_rules! assert_ready_ok { ($e:expr...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
1
60
tokio-rs/tokio:tokio/tests/timer_queue.rs:2
let mut queue = task::spawn(DelayQueue::new()); let _k = queue.insert_at("1", clock.now()); let _k = queue.insert_at("2", clock.now()); let _k = queue.insert_at("3", clock.now()); let mut res = vec![]; while res.len() < 3 { let entry = assert_ready_ok!(poll!(queue)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
41
100
tokio-rs/tokio:tokio/tests/timer_queue.rs:3
let entry = assert_ready_ok!(poll!(queue)); assert_eq!(*entry.get_ref(), "foo"); let entry = assert_ready!(poll!(queue)); assert!(entry.is_none()); }); } #[test] fn multi_delay_at_start() { let long = 262_144 + 9 * 4096; let delays = &[1000, 2, 234, long, 60, 10]; clock::mock(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
81
140
tokio-rs/tokio:tokio/tests/timer_queue.rs:4
} }); } #[test] fn insert_in_past_fires_immediately() { clock::mock(|clock| { let mut queue = task::spawn(DelayQueue::new()); let now = clock.now(); clock.turn_for(ms(10)); queue.insert_at("foo", now); assert_ready!(poll!(queue)); }); } #[test] fn remove_entry()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
121
180
tokio-rs/tokio:tokio/tests/timer_queue.rs:5
clock::mock(|clock| { let mut queue = task::spawn(DelayQueue::new()); let now = clock.now(); let key = queue.insert_at("foo", now + ms(5)); assert_pending!(poll!(queue)); clock.turn_for(ms(1)); queue.reset_at(&key, now + ms(10)); assert_pending!(poll!(queue));...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
161
220
tokio-rs/tokio:tokio/tests/timer_queue.rs:6
let key = queue.insert_at("foo", epoch + ms(200)); assert_pending!(poll!(queue)); clock.turn_for(ms(3)); queue.reset_at(&key, epoch + ms(5)); clock.turn_for(ms(20)); assert!(queue.is_woken()); }); } #[test] fn reset_twice() { // Reproduces tokio-rs/tokio#849. cl...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
201
260
tokio-rs/tokio:tokio/tests/timer_queue.rs:7
}); } #[test] fn remove_expired_item() { clock::mock(|clock| { let mut queue = DelayQueue::new(); let now = clock.now(); clock.turn_for(ms(10)); let key = queue.insert_at("foo", now); let entry = queue.remove(&key); assert_eq!(entry.into_inner(), "foo"); }) }...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
241
300
tokio-rs/tokio:tokio/tests/timer_queue.rs:8
let entry = assert_ready_ok!(poll!(queue)).into_inner(); assert_eq!(entry, "bar"); }) } #[test] fn multi_reset() { clock::mock(|clock| { let mut queue = task::spawn(DelayQueue::new()); let epoch = clock.now(); let foo = queue.insert_at("foo", epoch + ms(200)); let bar ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
281
340
tokio-rs/tokio:tokio/tests/timer_queue.rs:9
let entry = assert_ready_ok!(poll!(queue)).into_inner(); assert_eq!(entry, "foo"); }) } #[test] fn expire_second_key_when_reset_to_expire_earlier() { clock::mock(|clock| { let mut queue = task::spawn(DelayQueue::new()); let epoch = clock.now(); queue.insert_at("foo", epoch + m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
321
373
tokio-rs/tokio:tokio/tests/timer_queue.rs:10
queue.reset_at(&foo, epoch + ms(300)); clock.advance(ms(250)); assert!(queue.is_woken()); let entry = assert_ready_ok!(poll!(queue)).into_inner(); assert_eq!(entry, "bar"); }) } fn ms(n: u64) -> Duration { Duration::from_millis(n) }
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_queue.rs
361
373
tokio-rs/tokio:tokio/tests/timer_queue.rs:1
#![warn(rust_2018_idioms)] use tokio::timer::*; use tokio_test::{assert_ok, assert_pending, assert_ready}; use tokio_test::{clock, task}; use std::time::Duration; macro_rules! poll { ($queue:ident) => { $queue.enter(|cx, mut queue| queue.poll_next(cx)) }; } macro_rules! assert_ready_ok { ($e:exp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_queue.rs
MIT
966ccd5d5306adf6b6c39721331c2a3c32be6fa8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/timer_queue.rs
1
60
tokio-rs/tokio:tokio/tests/timer_rt.rs:1
#![warn(rust_2018_idioms)] use tokio::prelude::*; use tokio::time::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_rt.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_rt.rs
1
60
tokio-rs/tokio:tokio/tests/timer_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/timer_rt.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_rt.rs
41
90
tokio-rs/tokio:tokio/tests/timer_rt.rs:3
let (_tx, rx) = oneshot::channel::<()>(); let now = Instant::now(); let dur = Duration::from_millis(20); let res = rx.timeout(dur).await; assert!(res.is_err()); assert!(Instant::now() >= now + dur); }
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_rt.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_rt.rs
81
90
tokio-rs/tokio:tokio/tests/timer_rt.rs:1
#![warn(rust_2018_idioms)] use tokio::prelude::*; use tokio::timer::*; use std::sync::mpsc; use std::time::{Duration, Instant}; #[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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_rt.rs
MIT
d70c928d88dff9e3e8d673b8ee02bce131598550
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d70c928d88dff9e3e8d673b8ee02bce131598550/tokio/tests/timer_rt.rs
1
60
tokio-rs/tokio:tokio/tests/timer_throttle.rs:1
#![warn(rust_2018_idioms)] use tokio::sync::mpsc; use tokio::time::throttle::Throttle; use tokio_test::task; use tokio_test::{assert_pending, assert_ready_eq, clock}; use std::time::Duration; #[test] fn throttle() { clock::mock(|clock| { let (mut tx, rx) = mpsc::unbounded_channel(); let mut strea...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_throttle.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_throttle.rs
1
55
tokio-rs/tokio:tokio/tests/timer_throttle.rs:1
#![warn(rust_2018_idioms)] use tokio::sync::mpsc; use tokio::timer::throttle::Throttle; use tokio_test::task; use tokio_test::{assert_pending, assert_ready_eq, clock}; use std::time::Duration; #[test] fn throttle() { clock::mock(|clock| { let (mut tx, rx) = mpsc::unbounded_channel(); let mut stre...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_throttle.rs
MIT
966ccd5d5306adf6b6c39721331c2a3c32be6fa8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/timer_throttle.rs
1
55
tokio-rs/tokio:tokio/tests/timer_timeout.rs:1
#![warn(rust_2018_idioms)] use tokio::sync::oneshot; use tokio::time::*; use tokio_test::task; use tokio_test::{ assert_err, assert_pending, assert_ready, assert_ready_err, assert_ready_ok, clock, }; use std::time::Duration; #[test] fn simultaneous_deadline_future_completion() { clock::mock(|clock| { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_timeout.rs
1
60
tokio-rs/tokio:tokio/tests/timer_timeout.rs:2
let mut fut = task::spawn(Timeout::new_at(rx, clock.now() + ms(100))); assert_pending!(fut.poll()); // Turn the timer, it runs for the elapsed time clock.advance(ms(90)); assert_pending!(fut.poll()); // Complete the future tx.send(()).unwrap(); assert_ready_o...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_timeout.rs
41
100
tokio-rs/tokio:tokio/tests/timer_timeout.rs:3
struct Empty; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; impl Future for Empty { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { Poll::Pending } } #[test] fn deadline_now_elapses() { clock::mock(|clock| { // Wrap i...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_timeout.rs
81
140
tokio-rs/tokio:tokio/tests/timer_timeout.rs:4
use tokio::sync::mpsc; clock::mock(|clock| { // Not yet complete let (mut tx, rx) = mpsc::unbounded_channel(); // Wrap it with a deadline let mut stream = task::spawn(Timeout::new(rx, ms(100))); // Not ready assert_pending!(stream.poll_next()); // Turn the...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_timeout.rs
121
178
tokio-rs/tokio:tokio/tests/timer_timeout.rs:5
clock.advance(ms(100)); let v = assert_ready!(stream.poll_next()).unwrap(); assert_err!(v); // Stream's timeout should reset assert_pending!(stream.poll_next()); // Turn the timer, it runs for the elapsed time clock.advance(ms(100)); let v = assert_ready!(strea...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
7e35922a1d282b1e3dadf037cd237be336b331fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e35922a1d282b1e3dadf037cd237be336b331fb/tokio/tests/timer_timeout.rs
161
178
tokio-rs/tokio:tokio/tests/timer_timeout.rs:1
#![warn(rust_2018_idioms)] use tokio::sync::oneshot; use tokio::timer::*; use tokio_test::task; use tokio_test::{ assert_err, assert_pending, assert_ready, assert_ready_err, assert_ready_ok, clock, }; use std::time::Duration; #[test] fn simultaneous_deadline_future_completion() { clock::mock(|clock| { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
966ccd5d5306adf6b6c39721331c2a3c32be6fa8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/timer_timeout.rs
1
60
tokio-rs/tokio:tokio/tests/timer_timeout.rs:1
#![warn(rust_2018_idioms)] use tokio::sync::oneshot; use tokio::timer::*; use tokio_test::task::MockTask; use tokio_test::{ assert_err, assert_pending, assert_ready, assert_ready_err, assert_ready_ok, clock, }; use std::time::Duration; #[test] fn simultaneous_deadline_future_completion() { let mut t = MockTa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/timer_timeout.rs
1
60
tokio-rs/tokio:tokio/tests/timer_timeout.rs:2
let mut t = MockTask::new(); clock::mock(|clock| { // Not yet complete let (tx, rx) = oneshot::channel(); // Wrap it with a deadline let mut fut = Timeout::new_at(rx, clock.now() + ms(100)); assert_pending!(t.poll(&mut fut)); // Turn the timer, it runs for the ela...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/timer_timeout.rs
41
100
tokio-rs/tokio:tokio/tests/timer_timeout.rs:3
assert_pending!(t.poll(&mut fut)); // Complete the future tx.send(()).unwrap(); assert_ready_ok!(t.poll(&mut fut)).unwrap(); }); } struct Empty; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; impl Future for Empty { type Output = (); fn poll(self: P...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/timer_timeout.rs
81
140
tokio-rs/tokio:tokio/tests/timer_timeout.rs:4
// Wrap it with a deadline let mut fut = Timeout::new_at(Empty, clock.now() + ms(300)); assert_pending!(t.poll(&mut fut)); clock.advance(ms(300)); assert_ready_err!(t.poll(&mut fut)); }); } macro_rules! poll { ($task:ident, $stream:ident) => {{ use futures_core::Strea...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/timer_timeout.rs
121
180
tokio-rs/tokio:tokio/tests/timer_timeout.rs:5
tx.try_send(()).unwrap(); let item = assert_ready!(poll!(t, stream)); assert!(item.is_some()); }); } #[test] fn idle_stream_timesout_periodically() { use tokio::sync::mpsc; let mut t = MockTask::new(); clock::mock(|clock| { // Not yet complete let (_tx, rx) = mpsc::un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/timer_timeout.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/tests/timer_timeout.rs
161
202
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:1
//! Tests for sync instrumentation. //! //! These tests ensure that the instrumentation for tokio //! synchronization primitives is correct. use tokio::sync; use tracing_mock::{expect, subscriber}; #[tokio::test] async fn test_barrier_creates_span() { let barrier_span = expect::span() .named("runtime.reso...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/sync.rs
1
60
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:2
async fn test_mutex_creates_span() { let mutex_span = expect::span() .named("runtime.resource") .with_target("tokio::sync::mutex"); let locked_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(expect::field("locked").with_value(&false)); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/sync.rs
41
100
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:3
async fn test_oneshot_creates_span() { let oneshot_span = expect::span() .named("runtime.resource") .with_target("tokio::sync::oneshot"); let initial_tx_dropped_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(expect::field("tx_dropped").with_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/sync.rs
81
140
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:4
.named("runtime.resource.async_op.poll") .with_target("tokio::sync::oneshot"); let (subscriber, handle) = subscriber::mock() .new_span(oneshot_span.clone().with_explicit_parent(None)) .enter(oneshot_span.clone()) .event(initial_tx_dropped_event) .exit(oneshot_span.clone()) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/sync.rs
121
180
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:5
} #[tokio::test] async fn test_rwlock_creates_span() { let rwlock_span = expect::span() .named("runtime.resource") .with_target("tokio::sync::rwlock"); let max_readers_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(expect::field("max_reader...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/sync.rs
161
220
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:6
.exit(batch_semaphore_span.clone()) .exit(rwlock_span.clone()) .drop_span(rwlock_span) .drop_span(batch_semaphore_span) .run_with_handle(); { let _guard = tracing::subscriber::set_default(subscriber); let _ = sync::RwLock::new(true); } handle.assert_finished...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/sync.rs
201
248
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/sync.rs:2
async fn test_mutex_creates_span() { let mutex_span = expect::span() .named("runtime.resource") .with_target("tokio::sync::mutex"); let locked_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(expect::field("locked").with_value(&false)); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/sync.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/tests/tracing-instrumentation/tests/sync.rs
41
100
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:1
//! Tests for task instrumentation. //! //! These tests ensure that the instrumentation for task spawning and task //! lifecycles is correct. use std::{mem, time::Duration}; use tokio::task; use tracing_mock::{expect, span::NewSpan, subscriber}; #[tokio::test] async fn task_spawn_creates_span() { let task_span =...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/tests/tracing-instrumentation/tests/task.rs
1
60
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:2
.with_target("tokio::task") .with_field(expect::field("loc.file").with_value(&file!())); let (subscriber, handle) = subscriber::mock().new_span(task_span).run_with_handle(); { let _guard = tracing::subscriber::set_default(subscriber); tokio::spawn(futures::future::ready(())) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/tests/tracing-instrumentation/tests/task.rs
41
100
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:3
.with_field(expect::field("loc.file").with_value(&file!())); let (subscriber, handle) = subscriber::mock().new_span(task_span).run_with_handle(); { let _guard = tracing::subscriber::set_default(subscriber); task::Builder::new() .spawn(futures::future::ready(())) .unwra...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/tests/tracing-instrumentation/tests/task.rs
81
140
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:4
handle.assert_finished(); } #[tokio::test] async fn task_big_spawn_sizes_recorded() { let future = { async fn big<const N: usize>() { let mut a = [0_u8; N]; for (idx, item) in a.iter_mut().enumerate() { *item = (idx % 256) as u8; } tokio::time...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/tests/tracing-instrumentation/tests/task.rs
121
180
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:5
let _guard = tracing::subscriber::set_default(subscriber); task::Builder::new() .spawn(future) .unwrap() .await .expect("failed to await join handle"); } handle.assert_finished(); } /// Expect a task with name /// /// This is a convenience function to c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/tests/tracing-instrumentation/tests/task.rs
161
184
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:1
//! Tests for task instrumentation. //! //! These tests ensure that the instrumentation for task spawning and task //! lifecycles is correct. use tokio::task; use tracing_mock::{expect, span::NewSpan, subscriber}; #[tokio::test] async fn task_spawn_creates_span() { let task_span = expect::span() .named("r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
ed32cd194c47c9ad674c65cee5a5a901b387cb79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ed32cd194c47c9ad674c65cee5a5a901b387cb79/tokio/tests/tracing-instrumentation/tests/task.rs
1
60
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:2
let (subscriber, handle) = subscriber::mock().new_span(task_span).run_with_handle(); { let _guard = tracing::subscriber::set_default(subscriber); tokio::spawn(futures::future::ready(())) .await .expect("failed to await join handle"); } handle.assert_finished(); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
ed32cd194c47c9ad674c65cee5a5a901b387cb79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ed32cd194c47c9ad674c65cee5a5a901b387cb79/tokio/tests/tracing-instrumentation/tests/task.rs
41
100
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/task.rs:3
let (subscriber, handle) = subscriber::mock().new_span(task_span).run_with_handle(); { let _guard = tracing::subscriber::set_default(subscriber); task::Builder::new() .spawn(futures::future::ready(())) .unwrap() .await .expect("failed to await join h...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/task.rs
MIT
ed32cd194c47c9ad674c65cee5a5a901b387cb79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ed32cd194c47c9ad674c65cee5a5a901b387cb79/tokio/tests/tracing-instrumentation/tests/task.rs
81
107
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/time.rs:1
//! Tests for time resource instrumentation. //! //! These tests ensure that the instrumentation for tokio //! synchronization primitives is correct. use std::time::Duration; use tracing_mock::{expect, subscriber}; #[tokio::test] async fn test_sleep_creates_span() { let sleep_span = expect::span() .named(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/time.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/time.rs
1
60
tokio-rs/tokio:tokio/tests/tracing-instrumentation/tests/time.rs:2
.exit(sleep_span.clone()) .enter(async_op_span.clone()) .new_span( async_op_poll_span .clone() .with_contextual_parent(Some("runtime.resource.async_op")), ) .exit(async_op_span.clone()) .drop_span(async_op_span) .drop_span(async...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing-instrumentation/tests/time.rs
MIT
0cbf1a5adae81e8ff86ca6d040aeee67cf888262
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/tests/tracing-instrumentation/tests/time.rs
41
61
tokio-rs/tokio:tokio/tests/tracing_sync.rs:1
//! Tests for sync instrumentation. //! //! These tests ensure that the instrumentation for tokio //! synchronization primitives is correct. #![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))] use tokio::sync; use tracing_mock::{expect, subscriber}; #[tokio::test] as...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
1
60
tokio-rs/tokio:tokio/tests/tracing_sync.rs:2
} handle.assert_finished(); } #[tokio::test] async fn test_mutex_creates_span() { let mutex_span = expect::span() .named("runtime.resource") .with_target("tokio::sync::mutex"); let locked_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
41
100
tokio-rs/tokio:tokio/tests/tracing_sync.rs:3
{ let _guard = tracing::subscriber::set_default(subscriber); let _ = sync::Mutex::new(true); } handle.assert_finished(); } #[tokio::test] async fn test_oneshot_creates_span() { let oneshot_span_id = expect::id(); let oneshot_span = expect::span() .with_id(oneshot_span_id.clone(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
81
140
tokio-rs/tokio:tokio/tests/tracing_sync.rs:4
.with_fields(expect::field("value_sent.op").with_value(&"override")); let value_received_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(expect::field("value_received").with_value(&false)) .with_fields(expect::field("value_received.op").with_value(&"over...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
121
180
tokio-rs/tokio:tokio/tests/tracing_sync.rs:5
) .exit(&oneshot_span) .enter(&async_op_span) .new_span( async_op_poll_span .clone() .with_ancestry(expect::has_contextual_parent(&async_op_span_id)), ) .exit(&async_op_span) .enter(&oneshot_span) .event(final_tx_dropped...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
161
220
tokio-rs/tokio:tokio/tests/tracing_sync.rs:6
.with_fields(expect::field("write_locked").with_value(&false)); let current_readers_event = expect::event() .with_target("runtime::resource::state_update") .with_fields(expect::field("current_readers").with_value(&0_i64)); let batch_semaphore_span = expect::span() .named("runtime.resou...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
201
260
tokio-rs/tokio:tokio/tests/tracing_sync.rs:7
handle.assert_finished(); } #[tokio::test] async fn test_semaphore_creates_span() { let semaphore_span = expect::span() .named("runtime.resource") .with_target("tokio::sync::semaphore"); let batch_semaphore_span = expect::span() .named("runtime.resource") .with_target("tokio::s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_sync.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_sync.rs
241
282
tokio-rs/tokio:tokio/tests/tracing_task.rs:1
//! Tests for task instrumentation. //! //! These tests ensure that the instrumentation for task spawning and task //! lifecycles is correct. #![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))] use std::{mem, time::Duration}; use tokio::task; use tracing_mock::{expec...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_task.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_task.rs
1
60
tokio-rs/tokio:tokio/tests/tracing_task.rs:2
let task_span = expect::span() .named("runtime.spawn") .with_target("tokio::task") .with_fields(expect::field("loc.file").with_value(&file!())); let (subscriber, handle) = subscriber::mock().new_span(task_span).run_with_handle(); { let _guard = tracing::subscriber::set_default(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_task.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_task.rs
41
100