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:27
task::spawn(async move { spawned_tx.send(()).unwrap(); tx1.send(()).unwrap(); loop { rx2.recv().await.unwrap(); tx1.send(()).unwrap(); } }); task::spawn(asyn...
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,041
1,074
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 basic_scheduler { $($t)* fn rt() -> Arc<Runtime> { tokio::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:2
.threaded_scheduler() .core_threads(1) .enable_all() .build() .unwrap() .into() } } } } #[test] fn send_sync_bound() { use tokio::runtime::Runtime; fn is_send<T: Send + Sync>() {} is...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:3
rt.block_on(async { win = true; }); 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_mill...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:4
assert_eq!(out, "ZOMG"); } #[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" }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
121
180
tokio-rs/tokio:tokio/tests/rt_common.rs:5
assert_ok!(tx2.send(msg)); }); 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 { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/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]); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
201
260
tokio-rs/tokio:tokio/tests/rt_common.rs:7
.map(|i| { let (tx, rx) = oneshot::channel(); let done_tx = done_tx.clone(); tokio::spawn(async move { let msg = assert_ok!(rx.await); assert_eq!(i, msg); assert_o...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
241
300
tokio-rs/tokio:tokio/tests/rt_common.rs:8
fn spawn_await_chain() { let rt = rt(); let out = rt.block_on(async { assert_ok!(tokio::spawn(async { assert_ok!(tokio::spawn(async { "hello" }).await) }).await) }); assert_eq!(out, "hello"); } #[test]...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
281
340
tokio-rs/tokio:tokio/tests/rt_common.rs:9
let rt2 = rt(); rt1.block_on(async { rt2.block_on(async { "hello" }) }); } #[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 comp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
321
380
tokio-rs/tokio:tokio/tests/rt_common.rs:10
rt.block_on(async { let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); // Spin hard tokio::spawn(async { loop { yield_once().await; } }); thread::spawn(move || { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
361
420
tokio-rs/tokio:tokio/tests/rt_common.rs:11
rt.block_on(async move { assert_ok!(rx.await); }); } #[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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
}); assert!(now.elapsed() >= dur); } #[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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
TcpStream::connect(&addr).await.unwrap(); rx.await.unwrap(); }); } #[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" ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
rt.block_on(async move { assert_ok!(tokio::task::spawn_blocking(|| { let now = std::time::Instant::now(); let dur = Duration::from_millis(1); // use the futures' block_on fn to make sure we aren't setting // any Tokio context f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
fn spawn_blocking_after_shutdown() { let rt = rt(); let handle = rt.clone(); // Shutdown drop(rt); handle.enter(|| { let res = task::spawn_blocking(|| unreachable!()); // Avoid using a tokio runtime let out = futures::executor::block_on(res)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
time::sleep(Duration::from_millis(5)).await; }); }); 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 ass...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
let (mut stream, _) = assert_ok!(listener.accept().await); assert_ok!(stream.write_all(b"hello world").await); }); let cli = tokio::spawn(async move { let mut stream = assert_ok!(TcpStream::connect(addr).await); let mut dst = vec![0; 11]; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/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] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
}); assert_ok!(rt.block_on(handle)); } #[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>, _c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
}); drop(rt); 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)() } } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
let mut opt_tx1 = Some(tx1); let _d = OnDrop(move || { let tx1 = opt_tx1.take().unwrap(); h1.spawn(async move { tx1.send(()).unwrap(); }); }); let _ = rx2.await; }); rt.spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
tokio::spawn(async move { let mut buf = [0]; loop { recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::from_millis(2)); } }); tokio::spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
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 currently ignored on Windows because of a // rust-l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
tokio::spawn(async move { // 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![];...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
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()); } async fn client_server_local(tx: mpsc::Sender<()>) { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
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... time::sleep(Duration::from_millis(100)).await; poll_fn(|cx|...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
let (tx2, mut rx2) = mpsc::unbounded_channel(); let spawned_tx = spawned_tx.clone(); task::spawn(async move { spawned_tx.send(()).unwrap(); tx1.send(()).unwrap(); loop { rx2.recv().await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
60d81bbe10faf344ea18438a1c5ecb9173e6ec52
github
async-runtime
https://github.com/tokio-rs/tokio/blob/60d81bbe10faf344ea18438a1c5ecb9173e6ec52/tokio/tests/rt_common.rs
1,041
1,077
tokio-rs/tokio:tokio/tests/rt_common.rs:11
rt.block_on(async move { assert_ok!(rx.await); }); } #[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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
b704c53b9cc76eaf8c9c6585f8444c4515d27728
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/tests/rt_common.rs
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
}); assert!(now.elapsed() >= dur); } #[test] fn delay_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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
b704c53b9cc76eaf8c9c6585f8444c4515d27728
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
TcpStream::connect(&addr).await.unwrap(); rx.await.unwrap(); }); } #[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" ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
b704c53b9cc76eaf8c9c6585f8444c4515d27728
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:5
assert_ok!(tx2.send(msg)); }); 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 { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
066965cd59d01fd9d999152e32169a24dfe434fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/066965cd59d01fd9d999152e32169a24dfe434fa/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(); out }); assert_eq!(ITER, out.len()); for i in 0..ITER { assert_eq!(i, out[i]); } }...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
066965cd59d01fd9d999152e32169a24dfe434fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/066965cd59d01fd9d999152e32169a24dfe434fa/tokio/tests/rt_common.rs
201
260
tokio-rs/tokio:tokio/tests/rt_common.rs:7
.map(|i| { let (tx, rx) = oneshot::channel(); let done_tx = done_tx.clone(); tokio::spawn(async move { let msg = assert_ok!(rx.await); assert_eq!(i, msg); assert_o...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
066965cd59d01fd9d999152e32169a24dfe434fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/066965cd59d01fd9d999152e32169a24dfe434fa/tokio/tests/rt_common.rs
241
300
tokio-rs/tokio:tokio/tests/rt_common.rs:12
}); assert!(now.elapsed() >= dur); } #[test] fn delay_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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:14
rt.block_on(async move { assert_ok!(tokio::task::spawn_blocking(|| { let now = std::time::Instant::now(); let dur = Duration::from_millis(1); // use the futures' block_on fn to make sure we aren't setting // any Tokio context f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:16
time::sleep(Duration::from_millis(5)).await; }); }); 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 ass...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:23
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 currently ignored on Windows because of a // rust-l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
tokio::spawn(async move { // 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![];...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
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()); } async fn client_server_local(tx: mpsc::Sender<()>) { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:11
rt.block_on(async move { assert_ok!(rx.await); }); } #[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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
}); assert!(now.elapsed() >= dur); } #[test] fn delay_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 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
TcpStream::connect(&addr).await.unwrap(); rx.await.unwrap(); }); } #[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" ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
rt.block_on(async move { assert_ok!(tokio::task::spawn_blocking(|| { let now = std::time::Instant::now(); let dur = Duration::from_millis(1); // use the futures' block_on fn to make sure we aren't setting // any Tokio context f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
fn spawn_blocking_after_shutdown() { let rt = rt(); let handle = rt.clone(); // Shutdown drop(rt); handle.enter(|| { let res = task::spawn_blocking(|| unreachable!()); // Avoid using a tokio runtime let out = futures::executor::block_on(res)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
time::delay_for(Duration::from_millis(5)).await; }); }); 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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:21
let mut opt_tx1 = Some(tx1); let _d = OnDrop(move || { let tx1 = opt_tx1.take().unwrap(); h1.spawn(async move { tx1.send(()).unwrap(); }); }); let _ = rx2.await; }); rt.spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
tokio::spawn(async move { let mut buf = [0]; loop { recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::from_millis(2)); } }); tokio::spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
let runtime = rt(); runtime.block_on(async move { tokio::time::delay_for(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 // ru...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:25
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()); } async fn client_server_local(tx: mpsc::Sender<()>) { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
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... time::delay_for(Duration::from_millis(100)).await; poll_fn(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:21
let mut opt_tx1 = Some(tx1); let _d = OnDrop(move || { let tx1 = opt_tx1.take().unwrap(); h1.spawn(async move { tx1.send(()).unwrap(); }); }); let _ = rx2.await; }); rt.spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f25f12d57638a2928b3f738b3b1392d8773e276e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f25f12d57638a2928b3f738b3b1392d8773e276e/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
loop { recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::from_millis(2)); } }); tokio::spawn(async move { let buf = [0]; loop { se...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f25f12d57638a2928b3f738b3b1392d8773e276e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f25f12d57638a2928b3f738b3b1392d8773e276e/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
runtime.block_on(async move { tokio::time::delay_for(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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f25f12d57638a2928b3f738b3b1392d8773e276e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f25f12d57638a2928b3f738b3b1392d8773e276e/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
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).await.unwrap(); assert...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f25f12d57638a2928b3f738b3b1392d8773e276e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f25f12d57638a2928b3f738b3b1392d8773e276e/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 mut server = assert_ok!(TcpListener::bind("127.0.0.1:0").awai...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f25f12d57638a2928b3f738b3b1392d8773e276e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f25f12d57638a2928b3f738b3b1392d8773e276e/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
// Create a bunch of tasks let mut tasks = (0..1_000).map(|_| { tokio::spawn(async { }) }).collect::<Vec<_>>(); // Hope that all the tasks complete... time::delay_for(Duration::from_millis(100)).await; poll_fn(|cx| { // At lea...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
f25f12d57638a2928b3f738b3b1392d8773e276e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f25f12d57638a2928b3f738b3b1392d8773e276e/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:14
rt.block_on(async move { assert_ok!(tokio::task::spawn_blocking(|| { let now = std::time::Instant::now(); let dur = Duration::from_millis(1); // use the futures' block_on fn to make sure we aren't setting // any Tokio context f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
fn spawn_blocking_after_shutdown() { let rt = rt(); let handle = rt.clone(); // Shutdown drop(rt); handle.enter(|| { let res = task::spawn_blocking(|| unreachable!()); // Avoid using a tokio runtime let out = futures::executor::block_on(res)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
} // Do some I/O work rt.block_on(async { let mut 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().awai...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
struct Boom(Option<oneshot::Sender<()>>); impl Future for Boom { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { panic!(); } } impl Drop for Boom { fn drop(&mut self) { assert!...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
.await } #[test] fn enter_and_spawn() { let rt = rt(); let handle = rt.enter(|| { tokio::spawn(async {}) }); assert_ok!(rt.block_on(handle)); } #[test] fn eagerly_drops_futures_on_shutdown() { use std::sync::mpsc; struct Never { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
rt.block_on(async move { tokio::spawn(async move { assert_ok!(run_tx.send(())); Never { drop_tx }.await }); assert_ok!(run_rx.await); }); drop(rt); assert_ok!(drop_rx.recv()); } #[test] fn wake_while_rt_is_dropp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
rt.spawn(async move { // When this task is dropped, we'll be "closing remotes". // We spawn a new task that owns the `tx1`, to move its Drop // out of here. // // Importantly, the oneshot 1 has a waker already stored, so // the eventual drop here w...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
runtime.block_on(async { let socket = UdpSocket::bind((Ipv6Addr::LOCALHOST, 0)).await.unwrap(); let addr = socket.local_addr().unwrap(); let (mut recv_half, mut send_half) = socket.split(); tokio::spawn(async move { let mut buf = [0]; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_millis(100)); } #[test] fn shutdown_wakeup_time() { let runtime = rt(); runtime.block_on(async move { tokio::time::delay_for(std::time::Duration::from_millis(100)).await; }); Arc::try_unwrap(runt...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
let mut 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 (mut socket, _) = server.accept().await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
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).await }); assert_ok!(rx.try_recv()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
#[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 tasks com...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
let (spawned_tx, mut spawned_rx) = mpsc::unbounded_channel(); // Spawn a bunch of tasks that ping ping between each other to // saturate the runtime. for _ in 0..NUM { let (tx1, mut rx1) = mpsc::unbounded_channel(); let (tx2, mut rx2) = mpsc::unbounde...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/tests/rt_common.rs
1,001
1,043
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 basic_scheduler { $($t)* fn rt() -> Runtime { tokio::runti...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:2
.enable_all() .build() .unwrap() } } } } #[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::p...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:3
assert!(win); } #[test] fn block_on_handle_sync() { let rt = rt(); let mut win = false; rt.handle().block_on(async { win = true; }); assert!(win); } #[test] fn block_on_async() { let mut rt = rt(); let out = rt.block_on(asy...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:4
thread::spawn(move || { thread::sleep(Duration::from_millis(50)); tx.send("ZOMG").unwrap(); }); assert_ok!(rx.await) }); assert_eq!(out, "ZOMG"); } #[test] fn spawn_one_bg() { let mut rt = rt(); let out = rt.block_on...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
121
180
tokio-rs/tokio:tokio/tests/rt_common.rs:5
let msg = assert_ok!(rx.await); let out = assert_ok!(handle.await); assert_eq!(out, "DONE"); msg }); assert_eq!(out, "ZOMG"); } #[test] fn spawn_two() { let mut rt = rt(); let out = rt.block_on(async { let (tx1, rx1) = ones...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
161
220
tokio-rs/tokio:tokio/tests/rt_common.rs:6
let mut rt = rt(); let out = rt.block_on(async { let (done_tx, mut done_rx) = mpsc::unbounded_channel(); let mut txs = (0..ITER) .map(|i| { let (tx, rx) = oneshot::channel(); let done_tx = done_tx.clone(); tok...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
201
260
tokio-rs/tokio:tokio/tests/rt_common.rs:7
for i in 0..ITER { assert_eq!(i, out[i]); } } #[test] fn spawn_many_from_task() { use tokio::sync::mpsc; const ITER: usize = 500; let mut rt = rt(); let out = rt.block_on(async { tokio::spawn(async move { let (done_tx, mut d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
241
300
tokio-rs/tokio:tokio/tests/rt_common.rs:8
drop(done_tx); thread::spawn(move || { for (i, tx) in txs.drain(..).enumerate() { assert_ok!(tx.send(i)); } }); let mut out = vec![]; while let Some(i) = done_rx.recv().await { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
281
340
tokio-rs/tokio:tokio/tests/rt_common.rs:9
#[test] fn outstanding_tasks_dropped() { let mut rt = rt(); let cnt = Arc::new(()); rt.block_on(async { let cnt = cnt.clone(); tokio::spawn(poll_fn(move |_| { assert_eq!(2, Arc::strong_count(&cnt)); Poll::<()>::Pending })...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
321
380
tokio-rs/tokio:tokio/tests/rt_common.rs:10
#[test] fn complete_block_on_under_load() { let mut rt = rt(); rt.block_on(async { let (tx, rx) = oneshot::channel(); // Spin hard tokio::spawn(async { loop { yield_once().await; } }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
361
420
tokio-rs/tokio:tokio/tests/rt_common.rs:11
assert_ok!(tx1.send(())); }); tokio::spawn(async move { assert_ok!(rx1.await); assert_ok!(tx2.send(())); }); assert_ok!(rx2.await); }); } #[test] fn spawn_from_other_thread_idle() { let mut rt = rt(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
handle.spawn(async move { assert_ok!(tx.send(())); }); }); rt.block_on(async move { // Spin hard tokio::spawn(async { loop { yield_once().await; } }); assert_ok!(rx.await); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
tokio::spawn(async move { time::delay_for(dur).await; assert_ok!(tx.send(())); }); assert_ok!(rx.await); }); assert!(now.elapsed() >= dur); } #[test] fn block_on_socket() { let mut rt = rt(); rt.block_on(async move {...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
assert_ok!(inner.await) }); assert_eq!(out, "hello") } #[test] fn spawn_blocking_from_blocking() { let mut rt = rt(); let out = rt.block_on(async move { let inner = assert_ok!(tokio::task::spawn_blocking(|| { tokio::task::spawn_blocking(|| "hell...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
} #[test] fn socket_from_blocking() { let mut rt = rt(); rt.block_on(async move { let mut listener = assert_ok!(TcpListener::bind("127.0.0.1:0").await); let addr = assert_ok!(listener.local_addr()); let peer = tokio::task::spawn_blocking(move || { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
} #[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 (mutex), they yield their ownership. // // This tes...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
let mut dst = vec![0; 11]; assert_ok!(stream.read_exact(&mut dst).await); assert_eq!(dst, b"hello world"); }); assert_ok!(srv.await); assert_ok!(cli.await); }); } #[test] fn client_server_block_on() { let mut rt = rt(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
self.0.take().unwrap().send(()).unwrap(); } } rt.spawn(Boom(Some(tx))); assert_ok!(rt.block_on(rx)); } #[test] #[should_panic] fn panic_in_block_on() { let mut rt = rt(); rt.block_on(async { panic!() }); } async fn yield_once() { let...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
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<()> { Poll::Pending ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
#[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::channel(); let (tx2, rx2) = oneshot::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
}); let _ = rx2.await; }); rt.handle().spawn(async move { let _ = rx3.await; // 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(); }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/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::delay_for(Duration::from_millis(1)).await; } }); tokio::time::delay_for...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
// 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))] fn runtime_in_thread_local() { use std::cell::RefCell; use std::thread; thread...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[test] fn local_set_block_on_socket() { let mut rt = rt(); let local = task::LocalSet::new(); local.block_on(&mut rt, async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
async fn client_server_local(tx: mpsc::Sender<()>) { let mut 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 task::spawn_local(async move { // Accept a socket ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
poll_fn(|cx| { // At least one task should not be ready for task in &mut tasks { if Pin::new(task).poll(cx).is_pending() { return Ready(()); } } panic!("did not yield"); }).await;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
tx1.send(()).unwrap(); } }); task::spawn(async move { loop { rx1.recv().await.unwrap(); tx2.send(()).unwrap(); } }); } for _ in 0..NUM { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/tests/rt_common.rs
1,041
1,067
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 & therad-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod basic_scheduler { $($t)* fn rt() -> Runtime { tokio::runti...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
98e78314794607d0b402d5e45c66e3b8e38b819c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/98e78314794607d0b402d5e45c66e3b8e38b819c/tokio/tests/rt_common.rs
1
60
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::delay_for(Duration::from_millis(1)).await; } }); tokio::time::delay_for...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
98e78314794607d0b402d5e45c66e3b8e38b819c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/98e78314794607d0b402d5e45c66e3b8e38b819c/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
R.with(|cell| { *cell.borrow_mut() = Some(rt()); }); let _rt = rt(); }).join().unwrap(); } async fn client_server(tx: mpsc::Sender<()>) { let mut server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); // Get the assigned address le...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
98e78314794607d0b402d5e45c66e3b8e38b819c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/98e78314794607d0b402d5e45c66e3b8e38b819c/tokio/tests/rt_common.rs
881
940