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/rt_common.rs:19
cx.waker().wake_by_ref(); Poll::Pending } }) .await } #[test] fn enter_and_spawn() { let rt = rt(); let handle = { let _enter = rt.enter(); tokio::spawn(async {}) }; assert_ok!(rt.block_on(handle)); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on(async move { tokio::spawn(async move { assert_ok!(run_tx.send(())); Never { drop_tx }.await }); assert_ok!(run_r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
let barrier = Arc::new(Barrier::new(4)); let barrier1 = barrier.clone(); let barrier2 = barrier.clone(); let barrier3 = barrier.clone(); let rt = rt(); rt.spawn(async move { // Ensure a waker gets stored in oneshot 1. let _ = tokio::join!(rx1, barrier1.w...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
// Wait until every oneshot channel has been polled. rt.block_on(barrier.wait()); // Drop the rt drop(rt); // Make sure that the spawn actually happened assert!(drop_triggered.load(Ordering::Relaxed)); } #[cfg(not(target_os="wasi"))] // Wasi doesn't support UDP or bind...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
}); tokio::time::sleep(Duration::from_millis(5)).await; }); } } #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn shutdown_timeout() { let (tx, rx) = oneshot::channel(); let runtime = rt(); runtime.block_on(async move...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
#[test] fn shutdown_wakeup_time() { let runtime = rt(); runtime.block_on(async move { tokio::time::sleep(std::time::Duration::from_millis(100)).await; }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is current...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
// Get the assigned address let addr = assert_ok!(server.local_addr()); // Spawn the server tokio::spawn(async move { // Accept a socket let (mut socket, _) = server.accept().await.unwrap(); // Write some data socket.write_all(b"hello").await.unw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
rx.await.unwrap(); }); } #[cfg(not(tokio_wasi))] // Wasi does not support bind #[test] fn local_set_client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); let local = task::LocalSet::new(); local.block_on(&rt, async move { client_server_local...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
tx.send(()).unwrap(); } #[test] fn coop() { use std::task::Poll::Ready; use tokio::sync::mpsc; let rt = rt(); rt.block_on(async { let (send, mut recv) = mpsc::unbounded_channel(); // Send a bunch of messages. for _ in 0..1_000 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
// Send a bunch of messages. for _ in 0..1_000 { send.send(()).unwrap(); } tokio::task::unconstrained(poll_fn(|cx| { // All the responses should be ready. for _ in 0..1_000 { assert_eq!(recv.poll_recv(cx), Poll::Rea...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
} // Tests that the "next task" scheduler optimization is not able to starve // other tasks. #[test] fn ping_pong_saturation() { use std::sync::atomic::{Ordering, AtomicBool}; use tokio::sync::mpsc; const NUM: usize = 100; let rt = rt(); let running = Arc::new...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
tasks.push(task::spawn(async move { while rx1.recv().await.is_some() { tx2.send(()).unwrap(); } })); } for _ in 0..NUM { spawned_rx.recv().await.unwrap(); } // spawn another ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
1,161
1,186
tokio-rs/tokio:tokio/tests/rt_common.rs:26
rx.await.unwrap(); }); } #[cfg(not(tokio_wasi))] // Wasi does not support bind #[test] fn local_set_client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); let local = task::LocalSet::new(); local.block_on(&rt, async move { client_server_local...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
tx.send(()).unwrap(); } #[test] fn coop() { use std::task::Poll::Ready; let rt = rt(); rt.block_on(async { // Create a bunch of tasks let mut tasks = (0..1_000).map(|_| { tokio::spawn(async { }) }).collect::<Vec<_>>(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; tokio::task::unconstrained(poll_fn(|cx| { // All the tasks should be ready for task in &mut tasks { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:1
#![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] // Tests to run on both current-thread & thread-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { $($t)* fn rt() -> Arc<Runtime> { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:1
#![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] // Tests to run on both current-thread & thread-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { $($t)* fn rt() -> Arc<Runtime> { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:17
} // Do some I/O work rt.block_on(async { let listener = assert_ok!(TcpListener::bind("127.0.0.1:0").await); let addr = assert_ok!(listener.local_addr()); let srv = tokio::spawn(async move { let (mut stream, _) = assert_ok!(listener.accept().await); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
let rt = rt(); let (tx, rx) = oneshot::channel(); struct Boom(Option<oneshot::Sender<()>>); impl Future for Boom { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { panic!(); } } impl Drop ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:24
#[test] fn shutdown_wakeup_time() { let runtime = rt(); runtime.block_on(async move { tokio::time::sleep(std::time::Duration::from_millis(100)).await; }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is current...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
// Get the assigned address let addr = assert_ok!(server.local_addr()); // Spawn the server tokio::spawn(async move { // Accept a socket let (mut socket, _) = server.accept().await.unwrap(); // Write some data socket.write_all(b"hello").await.unw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
rx.await.unwrap(); }); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind #[test] fn local_set_client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); let local = task::LocalSet::new(); local.block_on(&rt, async move { client_serv...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:28
tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; tokio::task::unconstrained(poll_fn(|cx| { // All the tasks should be ready for task in &mut tasks { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
} // Tests that the "next task" scheduler optimization is not able to starve // other tasks. #[test] fn ping_pong_saturation() { use std::sync::atomic::{Ordering, AtomicBool}; use tokio::sync::mpsc; const NUM: usize = 100; let rt = rt(); let running = Arc::new...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:1
#![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] // Tests to run on both current-thread & thread-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { $($t)* fn rt() -> Arc<Runtime> { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:2
.build() .unwrap() .into() } } } } #[test] fn send_sync_bound() { use tokio::runtime::Runtime; fn is_send<T: Send + Sync>() {} is_send::<Runtime>(); } rt_test! { use tokio::net::{TcpListener, TcpStream, UdpSocket}; use tokio::io::{As...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:3
assert!(win); } #[test] fn block_on_async() { let rt = rt(); let out = rt.block_on(async { let (tx, rx) = oneshot::channel(); thread::spawn(move || { thread::sleep(Duration::from_millis(50)); tx.send("ZOMG").unwrap(); })...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:4
#[test] fn spawn_one_join() { let rt = rt(); let out = rt.block_on(async { let (tx, rx) = oneshot::channel(); let handle = tokio::spawn(async move { tx.send("ZOMG").unwrap(); "DONE" }); let msg = assert_ok!(rx.await);...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
121
180
tokio-rs/tokio:tokio/tests/rt_common.rs:5
assert_ok!(rx2.await) }); assert_eq!(out, "ZOMG"); } #[test] fn spawn_many_from_block_on() { use tokio::sync::mpsc; const ITER: usize = 200; let rt = rt(); let out = rt.block_on(async { let (done_tx, mut done_rx) = mpsc::unbounded_channel(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
161
220
tokio-rs/tokio:tokio/tests/rt_common.rs:6
let mut out = vec![]; while let Some(i) = done_rx.recv().await { out.push(i); } out.sort_unstable(); out }); assert_eq!(ITER, out.len()); for i in 0..ITER { assert_eq!(i, out[i]); } } #[test] fn s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
201
260
tokio-rs/tokio:tokio/tests/rt_common.rs:7
tokio::spawn(async move { let msg = assert_ok!(rx.await); assert_eq!(i, msg); assert_ok!(done_tx.send(msg)); }); tx }) .collect::<Vec<_>>(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
241
300
tokio-rs/tokio:tokio/tests/rt_common.rs:8
let out = rt.block_on(async { assert_ok!(tokio::spawn(async { assert_ok!(tokio::spawn(async { "hello" }).await) }).await) }); assert_eq!(out, "hello"); } #[test] fn outstanding_tasks_dropped() { let rt = rt...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
281
340
tokio-rs/tokio:tokio/tests/rt_common.rs:9
} #[test] fn create_rt_in_block_on() { let rt1 = rt(); let rt2 = rt1.block_on(async { rt() }); let out = rt2.block_on(async { "ZOMG" }); assert_eq!(out, "ZOMG"); } #[test] fn complete_block_on_under_load() { let rt = rt(); rt.block_on(async { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
321
380
tokio-rs/tokio:tokio/tests/rt_common.rs:10
let (tx2, rx2) = oneshot::channel(); // Spin hard tokio::spawn(async { loop { yield_once().await; } }); thread::spawn(move || { thread::sleep(Duration::from_millis(50)); assert_ok!(tx1.s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
361
420
tokio-rs/tokio:tokio/tests/rt_common.rs:11
}); } #[test] fn spawn_from_other_thread_under_load() { let rt = rt(); let handle = rt.clone(); let (tx, rx) = oneshot::channel(); thread::spawn(move || { handle.spawn(async move { assert_ok!(tx.send(())); }); }); rt...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
} #[test] fn sleep_in_spawn() { let rt = rt(); let now = Instant::now(); let dur = Duration::from_millis(50); rt.block_on(async move { let (tx, rx) = oneshot::channel(); tokio::spawn(async move { time::sleep(dur).await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
}); } #[test] fn spawn_from_blocking() { let rt = rt(); let out = rt.block_on(async move { let inner = assert_ok!(tokio::task::spawn_blocking(|| { tokio::spawn(async move { "hello" }) }).await); assert_ok!(inner.await) }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
let dur = Duration::from_millis(1); // use the futures' block_on fn to make sure we aren't setting // any Tokio context futures::executor::block_on(async { tokio::time::sleep(dur).await; }); assert!(now.elapsed() >= du...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
let rt = rt(); let rt2 = rt.clone(); let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let jh1 = thread::spawn(move || { rt.block_on(async move { rx2.await.unwrap(); time::sleep(Duration::from_millis(5)).aw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
// test is disabled. #[cfg(not(windows))] fn io_driver_called_when_under_load() { let rt = rt(); // Create a lot of constant load. The scheduler will always be busy. for _ in 0..100 { rt.spawn(async { loop { tokio::task::yield_now().await;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
let (tx, rx) = mpsc::channel(); rt.block_on(async move { client_server(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[test] fn panic_in_task() { let rt = rt(); let (tx, rx) = oneshot::channel(); struct Boom(Option<oneshot::Sender<...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
async fn yield_once() { let mut yielded = false; poll_fn(|cx| { if yielded { Poll::Ready(()) } else { yielded = true; cx.waker().wake_by_ref(); Poll::Pending } }) .await } #[test]...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
} impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on(async move { tokio::spa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
(self.0)() } } let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let (tx3, rx3) = oneshot::channel(); let barrier = Arc::new(Barrier::new(4)); let barrier1 = barrier.clone(); let barrier2 = barrier.clone(); let barrier...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
rt.spawn(async move { let _ = tokio::join!(rx3, barrier3.wait()); // We'll never get here, but once task 3 drops, this will // force task 2 to re-schedule since it's waiting on oneshot 2. tx2.send(()).unwrap(); }); // Wait until every oneshot channel has ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
tokio::spawn(async move { let buf = [0]; loop { send_half.send_to(&buf, &addr).await.unwrap(); tokio::time::sleep(Duration::from_millis(1)).await; } }); tokio::time::sleep(Duratio...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
let now = Instant::now(); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_nanos(0)); assert!(now.elapsed().as_secs() < 1); } #[test] fn shutdown_wakeup_time() { let runtime = rt(); runtime.block_on(async move { tokio::time::sleep(std::time::Dur...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
async fn client_server(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); // Get the assigned address let addr = assert_ok!(server.local_addr()); // Spawn the server tokio::spawn(async move { // Accept a socket let (...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
TcpStream::connect(&addr).await.unwrap(); rx.await.unwrap(); }); } #[test] fn local_set_client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); let local = task::LocalSet::new(); local.block_on(&rt, async move { client_server_local(tx)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
} #[test] fn coop() { use std::task::Poll::Ready; let rt = rt(); rt.block_on(async { // Create a bunch of tasks let mut tasks = (0..1_000).map(|_| { tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the ta...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
}).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; tokio::task::unconstrained(poll_fn(|cx| { // All the tasks should be ready for task in &mut tasks { assert!(Pin::new(tas...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
// Tests that the "next task" scheduler optimization is not able to starve // other tasks. #[test] fn ping_pong_saturation() { use std::sync::atomic::{Ordering, AtomicBool}; use tokio::sync::mpsc; const NUM: usize = 100; let rt = rt(); let running = Arc::new(Atomic...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
while rx1.recv().await.is_some() { tx2.send(()).unwrap(); } })); } for _ in 0..NUM { spawned_rx.recv().await.unwrap(); } // spawn another task and wait for it to complete let handle ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
88e8c6239c0a4e51127c0f66c5ff3daf1f01564d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/88e8c6239c0a4e51127c0f66c5ff3daf1f01564d/tokio/tests/rt_common.rs
1,121
1,145
tokio-rs/tokio:tokio/tests/rt_common.rs:26
} #[test] fn coop() { use std::task::Poll::Ready; let rt = rt(); rt.block_on(async { // Create a bunch of tasks let mut tasks = (0..1_000).map(|_| { tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the ta...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
ddf2f5fdf67691cf4b057343ad4dd0759730d12d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ddf2f5fdf67691cf4b057343ad4dd0759730d12d/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
}).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; tokio::task::unconstrained(poll_fn(|cx| { // All the tasks should be ready for task in &mut tasks { assert!(Pin::new(tas...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
ddf2f5fdf67691cf4b057343ad4dd0759730d12d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ddf2f5fdf67691cf4b057343ad4dd0759730d12d/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:19
} impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on(async move { tokio::spa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
(self.0)() } } let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let (tx3, rx3) = oneshot::channel(); let rt = rt(); rt.spawn(async move { // Ensure a waker gets stored in oneshot 1. let _ = rx1.await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
tx2.send(()).unwrap(); }); // Tick the loop rt.block_on(async { task::yield_now().await; }); // Drop the rt drop(rt); // Make sure that the spawn actually happened assert!(drop_triggered.load(Ordering::Relaxed)); } #[test] fn io...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
send_half.send_to(&buf, &addr).await.unwrap(); tokio::time::sleep(Duration::from_millis(1)).await; } }); tokio::time::sleep(Duration::from_millis(5)).await; }); } } #[test] fn shutdown_timeout() { let (...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
} #[test] fn shutdown_wakeup_time() { let runtime = rt(); runtime.block_on(async move { tokio::time::sleep(std::time::Duration::from_millis(100)).await; }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
// Get the assigned address let addr = assert_ok!(server.local_addr()); // Spawn the server tokio::spawn(async move { // Accept a socket let (mut socket, _) = server.accept().await.unwrap(); // Write some data socket.write_all(b"hello").await.unw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
} #[test] fn local_set_client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); let local = task::LocalSet::new(); local.block_on(&rt, async move { client_server_local(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
fn coop() { use std::task::Poll::Ready; let rt = rt(); rt.block_on(async { // Create a bunch of tasks let mut tasks = (0..1_000).map(|_| { tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
time::sleep(Duration::from_millis(100)).await; tokio::task::unconstrained(poll_fn(|cx| { // All the tasks should be ready for task in &mut tasks { assert!(Pin::new(task).poll(cx).is_ready()); } Ready(()) })).aw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
while running.load(Ordering::Relaxed) { tx1.send(()).unwrap(); rx2.recv().await.unwrap(); } // Close the channel and wait for the other task to exit. drop(tx1); assert!(rx2.recv().await.is_no...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
454ac1c54fa992004787c109e61bf232697d3652
github
async-runtime
https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/rt_common.rs
1,081
1,117
tokio-rs/tokio:tokio/tests/rt_common.rs:19
} impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on(async move { tokio::spa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let (tx3, rx3) = oneshot::channel(); let rt = rt(); let h1 = rt.clone(); rt.spawn(async move { // Ensure a waker gets stored in oneshot 1. let _ = rx1.await; tx3.send(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
task::yield_now().await; }); // Drop the rt drop(rt); } #[test] fn io_notify_while_shutting_down() { use std::net::Ipv6Addr; use std::sync::Arc; for _ in 1..10 { let runtime = rt(); runtime.block_on(async { let socke...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
} #[test] fn shutdown_timeout() { let (tx, rx) = oneshot::channel(); let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { tx.send(()).unwrap(); thread::sleep(Duration::from_secs(10_000)); }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
}); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is currently ignored on Windows because of a // rust-lang issue in thread local storage destructors. // See https://github.com/rust-lang/rust/issues/74875 #[test] #[cfg(not(windows))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
// Write some data socket.write_all(b"hello").await.unwrap(); }); let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[tes...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
local.block_on(&rt, async move { client_server_local(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } async fn client_server_local(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); // Get the assigned address ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; poll_fn(|cx| { // At least one task should not be ready for task in &mut tasks { if ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
Ready(()) })).await; }); } // Tests that the "next task" scheduler optimization is not able to starve // other tasks. #[test] fn ping_pong_saturation() { use std::sync::atomic::{Ordering, AtomicBool}; use tokio::sync::mpsc; const NUM: usize = 100; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
assert!(rx2.recv().await.is_none()); })); tasks.push(task::spawn(async move { while rx1.recv().await.is_some() { tx2.send(()).unwrap(); } })); } for _ in 0..NUM { spa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/tests/rt_common.rs
1,081
1,109
tokio-rs/tokio:tokio/tests/rt_common.rs:25
local.block_on(&rt, async move { client_server_local(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } async fn client_server_local(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); // Get the assigned address ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
117fc2ef3e948c92dd5359d3a479906ed7a5ceb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/117fc2ef3e948c92dd5359d3a479906ed7a5ceb4/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; poll_fn(|cx| { // At least one task should not be ready for task in &mut tasks { if ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
117fc2ef3e948c92dd5359d3a479906ed7a5ceb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/117fc2ef3e948c92dd5359d3a479906ed7a5ceb4/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:26
tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; poll_fn(|cx| { // At least one task should not be ready for task in &mut tasks { if ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
78f2340d259487d4470681f97cc4b5eac719e178
github
async-runtime
https://github.com/tokio-rs/tokio/blob/78f2340d259487d4470681f97cc4b5eac719e178/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
spawned_tx.send(()).unwrap(); tx1.send(()).unwrap(); loop { rx2.recv().await.unwrap(); tx1.send(()).unwrap(); } }); task::spawn(async move { loop { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
78f2340d259487d4470681f97cc4b5eac719e178
github
async-runtime
https://github.com/tokio-rs/tokio/blob/78f2340d259487d4470681f97cc4b5eac719e178/tokio/tests/rt_common.rs
1,041
1,073
tokio-rs/tokio:tokio/tests/rt_common.rs:1
#![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] // Tests to run on both current-thread & thread-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { $($t)* fn rt() -> Arc<Runtime> { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a85fdb884d961bb87a2f3d446c548802868e54cb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a85fdb884d961bb87a2f3d446c548802868e54cb/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:2
.build() .unwrap() .into() } } } } #[test] fn send_sync_bound() { use tokio::runtime::Runtime; fn is_send<T: Send + Sync>() {} is_send::<Runtime>(); } rt_test! { use tokio::net::{TcpListener, TcpStream, UdpSocket}; use tokio::prelude...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a85fdb884d961bb87a2f3d446c548802868e54cb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a85fdb884d961bb87a2f3d446c548802868e54cb/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:22
} #[test] fn shutdown_timeout() { let (tx, rx) = oneshot::channel(); let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { tx.send(()).unwrap(); thread::sleep(Duration::from_secs(10_000)); }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
00b6127f2ed3125f8b305ab4fd9bb90e99762785
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
static R: RefCell<Option<Runtime>> = RefCell::new(None); ); thread::spawn(|| { R.with(|cell| { let rt = rt(); let rt = Arc::try_unwrap(rt).unwrap(); *cell.borrow_mut() = Some(rt); }); let _rt = rt(); }).join()....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
00b6127f2ed3125f8b305ab4fd9bb90e99762785
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
let rt = rt(); let local = task::LocalSet::new(); local.block_on(&rt, async move { let (tx, rx) = oneshot::channel(); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); task::spawn_local(async move...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
00b6127f2ed3125f8b305ab4fd9bb90e99762785
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
// Accept a socket let (mut socket, _) = server.accept().await.unwrap(); // Write some data socket.write_all(b"hello").await.unwrap(); }); let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf)....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
00b6127f2ed3125f8b305ab4fd9bb90e99762785
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
}).await; }); } // Tests that the "next task" scheduler optimization is not able to starve // other tasks. #[test] fn ping_pong_saturation() { use tokio::sync::mpsc; const NUM: usize = 100; let rt = rt(); rt.block_on(async { let (spawned_tx, mu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
00b6127f2ed3125f8b305ab4fd9bb90e99762785
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/tests/rt_common.rs
1,001
1,058
tokio-rs/tokio:tokio/tests/rt_common.rs:27
}); } for _ in 0..NUM { spawned_rx.recv().await.unwrap(); } // spawn another task and wait for it to complete let handle = task::spawn(async { for _ in 0..5 { // Yielding forces it back into the local queue...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
00b6127f2ed3125f8b305ab4fd9bb90e99762785
github
async-runtime
https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/tests/rt_common.rs
1,041
1,058
tokio-rs/tokio:tokio/tests/rt_common.rs:14
let dur = Duration::from_millis(1); // use the futures' block_on fn to make sure we aren't setting // any Tokio context futures::executor::block_on(async { tokio::time::sleep(dur).await; }); assert!(now.elapsed() >= du...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
// Shutdown drop(rt); handle.enter(|| { let res = task::spawn_blocking(|| unreachable!()); // Avoid using a tokio runtime let out = futures::executor::block_on(res); assert!(out.is_err()); }); } #[test] fn always_active_parker() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
jh1.join().unwrap(); jh2.join().unwrap(); } #[test] // IOCP requires setting the "max thread" concurrency value. The sane, // default, is to set this to the number of cores. Threads that poll I/O // become associated with the IOCP handle. Once those threads sleep for any // reason (mute...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
let cli = tokio::spawn(async move { let mut stream = assert_ok!(TcpStream::connect(addr).await); let mut dst = vec![0; 11]; assert_ok!(stream.read_exact(&mut dst).await); assert_eq!(dst, b"hello world"); }); assert_ok!(srv.await);...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
impl Drop for Boom { fn drop(&mut self) { assert!(std::thread::panicking()); self.0.take().unwrap().send(()).unwrap(); } } rt.spawn(Boom(Some(tx))); assert_ok!(rt.block_on(rx)); } #[test] #[should_panic] fn panic_in_block_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
} #[test] fn eagerly_drops_futures_on_shutdown() { use std::sync::mpsc; struct Never { drop_tx: mpsc::Sender<()>, } impl Future for Never { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
assert_ok!(drop_rx.recv()); } #[test] fn wake_while_rt_is_dropping() { use tokio::task; struct OnDrop<F: FnMut()>(F); impl<F: FnMut()> Drop for OnDrop<F> { fn drop(&mut self) { (self.0)() } } let (tx1, rx1) = oneshot::channe...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
h1.spawn(async move { tx1.send(()).unwrap(); }); }); let _ = rx2.await; }); rt.spawn(async move { let _ = rx3.await; // We'll never get here, but once task 3 drops, this will // force task 2 to re-schedule s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::from_millis(2)); } }); tokio::spawn(async move { let buf = [0]; loop { send_half.send_to(&buf, &addr).aw...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
tokio::time::sleep(std::time::Duration::from_millis(100)).await; }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is currently ignored on Windows because of a // rust-lang issue in thread local storage destructors. // See https://githu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
// Write some data socket.write_all(b"hello").await.unwrap(); }); let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[tes...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
let local = task::LocalSet::new(); local.block_on(&rt, async move { client_server_local(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } async fn client_server_local(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
let mut tasks = (0..1_000).map(|_| { tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::sleep(Duration::from_millis(100)).await; poll_fn(|cx| { // At least one task should not be ready ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/rt_common.rs
1,001
1,060