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:2
mod threaded_scheduler_1_thread { $($t)* const NUM_WORKERS: usize = 1; fn rt() -> Arc<Runtime> { tokio::runtime::Builder::new_multi_thread() .worker_threads(1) .enable_all() .build() .un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:21
tokio::task::yield_now().await; cnt += 1; if cnt >= 10 { // yielded too many times; report failure and // sleep forever so that the `fail_test` branch // of the `selec...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
rt.block_on(async move { client_server(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[cfg_attr(tokio_wasi, ignore = "Wasi does not support threads or panic recovery")] #[test] fn panic_in_task() { let rt = rt(); let (tx, rx) = oneshot::channel(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:28
thread::sleep(Duration::from_secs(10_000)); }); }); 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(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
let _rt = rt(); }).join().unwrap(); } #[cfg(not(target_os="wasi"))] // Wasi does not support bind 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_a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
let addr = listener.local_addr().unwrap(); task::spawn_local(async move { let _ = listener.accept().await; tx.send(()).unwrap(); }); TcpStream::connect(&addr).await.unwrap(); rx.await.unwrap(); }); } #[cfg(not(tokio_wasi)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
1,161
1,220
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 & multi-thread runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { $($t)* #[cfg(not(target_os="wasi"))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:2
mod threaded_scheduler_1_thread { $($t)* const NUM_WORKERS: usize = 1; fn rt() -> Arc<Runtime> { tokio::runtime::Builder::new_multi_thread() .worker_threads(1) .enable_all() .build() .un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:3
use std::future::Future; use std::pin::Pin; #[cfg(not(target_os="wasi"))] use std::sync::mpsc; use std::sync::Arc; use std::task::{Context, Poll}; #[cfg(not(target_os="wasi"))] use std::thread; use std::time::{Duration, Instant}; #[test] fn block_on_sync() { let rt = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:13
rt.block_on(async move { time::sleep(dur).await; }); 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) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
let _ = listener.accept().await; tx.send(()).unwrap(); }); TcpStream::connect(&addr).await.unwrap(); rx.await.unwrap(); }); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn spawn_from_blocking() { let rt = r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
#[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn sleep_from_blocking() { let rt = rt(); rt.block_on(async move { assert_ok!(tokio::task::spawn_blocking(|| { let now = std::time::Instant::now(); let dur = Duration::from_millis(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
let _ = assert_ok!(listener.accept().await); assert_ok!(peer.await); }); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn always_active_parker() { // This test it to show that we will always have // an active parker even if we call block_o...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
// 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 test hits an edge case...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
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
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
/// Implementation of `yield_defers_until_park` test. Returns `true` if the /// test passed. #[cfg(not(target_os="wasi"))] fn yield_defers_until_park_inner() -> bool { use std::sync::atomic::{AtomicBool, Ordering::SeqCst}; use std::sync::Barrier; let rt = rt(); let flag = A...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
// Done in a blocking manner intentionally. let _socket = std::net::TcpStream::connect(addr).unwrap(); // Yield until connected let mut cnt = 0; while !flag.load(SeqCst){ tokio::task::yield_now()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
#[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); rt.block_on(async move { client_server(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
#[should_panic] #[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] fn panic_in_block_on() { let rt = rt(); rt.block_on(async { panic!() }); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads async fn yield_once() { let mut yielded = false;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
impl Future for Never { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { Poll::Pending } } impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
let drop_triggered = Arc::new(AtomicBool::new(false)); let set_drop_triggered = drop_triggered.clone(); struct OnDrop<F: FnMut()>(F); impl<F: FnMut()> Drop for OnDrop<F> { fn drop(&mut self) { (self.0)() } } let (tx1, rx1) = oneshot::cha...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
tx1.send(()).unwrap(); }); // Just a sanity check that this entire thing actually happened set_drop_triggered.store(true, Ordering::Relaxed); }); let _ = tokio::join!(rx2, barrier2.wait()); }); rt.spawn(async move { let...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
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
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
#[test] fn shutdown_timeout_0() { let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { thread::sleep(Duration::from_secs(10_000)); }); }); let now = Instant::now(); Arc::try_unwrap(runtime).unwrap().shutdow...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
thread::spawn(|| { R.with(|cell| { let rt = rt(); let rt = Arc::try_unwrap(rt).unwrap(); *cell.borrow_mut() = Some(rt); }); let _rt = rt(); }).join().unwrap(); } #[cfg(not(target_os="wasi"))] // Wasi does not support b...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
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 { let ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
task::spawn_local(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 = ve...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
panic!("did not yield"); }).await; }); } #[test] fn coop_unconstrained() { 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 o...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
let mut worker = Box::pin(async move { // Consume the budget until a yield happens for _ in 0..1000 { *counter.lock().unwrap() += 1; task::consume_budget().await } }); // Assert th...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,241
1,300
tokio-rs/tokio:tokio/tests/rt_common.rs:33
tasks.push(task::spawn(async move { spawned_tx.send(()).unwrap(); while running.load(Ordering::Relaxed) { tx1.send(()).unwrap(); rx2.recv().await.unwrap(); } // Close the channel and wait f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,281
1,340
tokio-rs/tokio:tokio/tests/rt_common.rs:34
#[test] #[cfg(not(target_os="wasi"))] fn shutdown_concurrent_spawn() { const NUM_TASKS: usize = 10_000; for _ in 0..5 { let (tx, rx) = std::sync::mpsc::channel(); let rt = rt(); let mut txs = vec![]; for _ in 0..NUM_TASKS { let (t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
93bde0870fd706afbca795b94ce6e46d1f878edb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/93bde0870fd706afbca795b94ce6e46d1f878edb/tokio/tests/rt_common.rs
1,321
1,355
tokio-rs/tokio:tokio/tests/rt_common.rs:33
tasks.push(task::spawn(async move { spawned_tx.send(()).unwrap(); while running.load(Ordering::Relaxed) { tx1.send(()).unwrap(); rx2.recv().await.unwrap(); } // Close the channel and wait f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
b9868b23aaf68c0f4837bf3c6f9caf97d9d6420c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b9868b23aaf68c0f4837bf3c6f9caf97d9d6420c/tokio/tests/rt_common.rs
1,281
1,320
tokio-rs/tokio:tokio/tests/rt_common.rs:17
// 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 test hits an edge case...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
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
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
while !flag.load(SeqCst) { std::thread::sleep(std::time::Duration::from_millis(1)); } }); } barrier.wait(); tokio::spawn(async move { // Create a TCP litener let listener = TcpListener::bind...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
#[test] fn client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); rt.block_on(async move { client_server(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[cfg_attr(tokio_wasi, ignore = "Wasi does not support threads or pani...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
#[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] fn panic_in_block_on() { let rt = rt(); rt.block_on(async { panic!() }); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads async fn yield_once() { let mut yielded = false; poll_fn(|cx...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
impl Future for Never { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { Poll::Pending } } impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
let set_drop_triggered = drop_triggered.clone(); 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::channel(); le...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
}); // Just a sanity check that this entire thing actually happened set_drop_triggered.store(true, Ordering::Relaxed); }); let _ = tokio::join!(rx2, barrier2.wait()); }); rt.spawn(async move { let _ = tokio::join!(rx3, barrier3.wait())...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
let mut buf = [0]; loop { recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::from_millis(2)); } }); tokio::spawn(async move { let buf = [0]; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
fn shutdown_timeout_0() { let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { thread::sleep(Duration::from_secs(10_000)); }); }); let now = Instant::now(); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Du...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
R.with(|cell| { let rt = rt(); let rt = Arc::try_unwrap(rt).unwrap(); *cell.borrow_mut() = Some(rt); }); let _rt = rt(); }).join().unwrap(); } #[cfg(not(target_os="wasi"))] // Wasi does not support bind async fn client_server(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
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 { let _ = listener.accept().await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
// 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
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
}).await; }); } #[test] fn coop_unconstrained() { 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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
// Consume the budget until a yield happens for _ in 0..1000 { *counter.lock().unwrap() += 1; task::consume_budget().await } }); // Assert that the worker was yielded and it didn't manage ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
spawned_tx.send(()).unwrap(); 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)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22cff80048c62ed0fa20065888667d00d5aedd14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/rt_common.rs
1,241
1,279
tokio-rs/tokio:tokio/tests/rt_common.rs:17
// 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 test hits an edge case...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
22862739dddd49a94065aa7a917cde2dc8a3f6bc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22862739dddd49a94065aa7a917cde2dc8a3f6bc/tokio/tests/rt_common.rs
641
700
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 & multi-thread 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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:2
.worker_threads(1) .enable_all() .build() .unwrap() .into() } } } } #[test] fn send_sync_bound() { use tokio::runtime::Runtime; fn is_send<T: Send + Sync>() {} is_send::<Runtime>(); } rt_test! { #[...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:3
use std::task::{Context, Poll}; #[cfg(not(target_os="wasi"))] use std::thread; use std::time::{Duration, Instant}; #[test] fn block_on_sync() { let rt = rt(); let mut win = false; rt.block_on(async { win = true; }); assert!(win); } #[...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:4
let rt = rt(); let out = rt.block_on(async { let (tx, rx) = oneshot::channel(); tokio::spawn(async move { tx.send("ZOMG").unwrap(); }); assert_ok!(rx.await) }); assert_eq!(out, "ZOMG"); } #[test] fn spawn_one_join()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
121
180
tokio-rs/tokio:tokio/tests/rt_common.rs:5
let rt = rt(); let out = rt.block_on(async { let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); tokio::spawn(async move { assert_ok!(tx1.send("ZOMG")); }); tokio::spawn(async move { let msg = as...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
161
220
tokio-rs/tokio:tokio/tests/rt_common.rs:6
assert_eq!(i, msg); assert_ok!(done_tx.send(msg)); }); tx }) .collect::<Vec<_>>(); drop(done_tx); thread::spawn(move || { for (i, tx) in txs.drain(..).enumerate() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
201
260
tokio-rs/tokio:tokio/tests/rt_common.rs:7
let out = rt.block_on(async { tokio::spawn(async move { 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.clo...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
241
300
tokio-rs/tokio:tokio/tests/rt_common.rs:9
}); assert_eq!(out, "hello"); } #[test] fn outstanding_tasks_dropped() { let 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)); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
321
380
tokio-rs/tokio:tokio/tests/rt_common.rs:10
let out = rt2.block_on(async { "ZOMG" }); assert_eq!(out, "ZOMG"); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn complete_block_on_under_load() { let rt = rt(); rt.block_on(async { let (tx, rx) = oneshot::channel(); // Spi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
361
420
tokio-rs/tokio:tokio/tests/rt_common.rs:11
loop { yield_once().await; } }); thread::spawn(move || { thread::sleep(Duration::from_millis(50)); assert_ok!(tx1.send(())); }); tokio::spawn(async move { assert_ok!(rx1.await); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
#[cfg(not(target_os="wasi"))] // Wasi does not support threads #[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!(t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
#[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; assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
} #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[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" }) }).awai...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
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 futures::executor::block_on(async { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
#[test] fn always_active_parker() { // This test it to show that we will always have // an active parker even if we call block_on concurrently let rt = rt(); let rt2 = rt.clone(); let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
601
660
tokio-rs/tokio:tokio/tests/rt_common.rs:17
// IOCP gets "starved". // // For now, this is a very edge case that is probably not a real production // concern. There also isn't a great/obvious solution to take. For now, the // test is disabled. #[cfg(not(windows))] #[cfg(not(target_os="wasi"))] // Wasi does not support bind or threads ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
} #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); rt.block_on(async move { client_server(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
#[test] #[should_panic] #[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] fn panic_in_block_on() { let rt = rt(); rt.block_on(async { panic!() }); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads async fn yield_once() { let mut yiel...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
drop_tx: mpsc::Sender<()>, } impl Future for Never { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { Poll::Pending } } impl Drop for Never { fn drop(&mut self) { self.d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
use core::sync::atomic::{AtomicBool, Ordering}; let drop_triggered = Arc::new(AtomicBool::new(false)); let set_drop_triggered = drop_triggered.clone(); 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
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
let tx1 = opt_tx1.take().unwrap(); h1.spawn(async move { tx1.send(()).unwrap(); }); // Just a sanity check that this entire thing actually happened set_drop_triggered.store(true, Ordering::Relaxed); }); let _ = t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
let recv_half = send_half.clone(); tokio::spawn(async move { let mut buf = [0]; loop { recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::from_millis(2)); } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
#[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn shutdown_timeout_0() { let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { thread::sleep(Duration::from_secs(10_000)); }); }); let now ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
); thread::spawn(|| { R.with(|cell| { let rt = rt(); let rt = Arc::try_unwrap(rt).unwrap(); *cell.borrow_mut() = Some(rt); }); let _rt = rt(); }).join().unwrap(); } #[cfg(not(target_os="wasi"))] // Wasi does n...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
fn local_set_block_on_socket() { 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(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
// Spawn the server task::spawn_local(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(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
} panic!("did not yield"); }).await; }); } #[test] fn coop_unconstrained() { use std::task::Poll::Ready; use tokio::sync::mpsc; let rt = rt(); rt.block_on(async { let (send, mut recv) = mpsc::unbounded_channel(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
let counter = Arc::new(std::sync::Mutex::new(0)); let counter_clone = Arc::clone(&counter); let mut worker = Box::pin(async move { // Consume the budget until a yield happens for _ in 0..1000 { *counter.lock().unwrap() += 1;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
let spawned_tx = spawned_tx.clone(); let running = running.clone(); tasks.push(task::spawn(async move { spawned_tx.send(()).unwrap(); while running.load(Ordering::Relaxed) { tx1.send(()).unwrap(); r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_common.rs
1,161
1,202
tokio-rs/tokio:tokio/tests/rt_common.rs:22
let tx1 = opt_tx1.take().unwrap(); h1.spawn(async move { tx1.send(()).unwrap(); }); // Just a sanity check that this entire thing actually happened set_drop_triggered.store(true, Ordering::Relaxed); }); let _ = t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
let send_half = Arc::new(socket); let recv_half = send_half.clone(); tokio::spawn(async move { let mut buf = [0]; loop { recv_half.recv_from(&mut buf).await.unwrap(); std::thread::sleep(Duration::fro...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
} #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn shutdown_timeout_0() { let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { thread::sleep(Duration::from_secs(10_000)); }); }); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
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
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
#[test] fn local_set_block_on_socket() { 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(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
let addr = assert_ok!(server.local_addr()); // Spawn the server task::spawn_local(async move { // Accept a socket let (mut socket, _) = server.accept().await.unwrap(); // Write some data socket.write_all(b"hello").await.unwrap(); }); let...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
} } panic!("did not yield"); }).await; }); } #[test] fn coop_unconstrained() { use std::task::Poll::Ready; use tokio::sync::mpsc; let rt = rt(); rt.block_on(async { let (send, mut recv) = mpsc::unbounded_chan...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
poll_fn(|cx| { let counter = Arc::new(std::sync::Mutex::new(0)); let counter_clone = Arc::clone(&counter); let mut worker = Box::pin(async move { // Consume the budget until a yield happens for _ in 0..1000 { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
let (tx2, mut rx2) = mpsc::unbounded_channel(); let spawned_tx = spawned_tx.clone(); let running = running.clone(); tasks.push(task::spawn(async move { spawned_tx.send(()).unwrap(); while running.load(Ordering::Relaxed) { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
53cba023dac45c2ab697bd1ead6c86cf4da3561c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53cba023dac45c2ab697bd1ead6c86cf4da3561c/tokio/tests/rt_common.rs
1,161
1,203
tokio-rs/tokio:tokio/tests/rt_common.rs:6
assert_eq!(i, msg); assert_ok!(done_tx.send(msg)); }); tx }) .collect::<Vec<_>>(); drop(done_tx); thread::spawn(move || { for (i, tx) in txs.drain(..).enumerate() { ...
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
201
260
tokio-rs/tokio:tokio/tests/rt_common.rs:7
let out = rt.block_on(async { tokio::spawn(async move { let (done_tx, mut done_rx) = mpsc::unbounded_channel(); /* for _ in 0..100 { tokio::spawn(async move { }); } tokio::task::yield_now().await; ...
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
241
300
tokio-rs/tokio:tokio/tests/rt_common.rs:8
out.sort_unstable(); out }).await.unwrap() }); assert_eq!(ITER, out.len()); for i in 0..ITER { assert_eq!(i, out[i]); } } #[test] fn spawn_await_chain() { let rt = rt(); let out = rt.block_on(async { asse...
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
281
340
tokio-rs/tokio:tokio/tests/rt_common.rs:9
})); }); assert_eq!(2, Arc::strong_count(&cnt)); drop(rt); assert_eq!(1, Arc::strong_count(&cnt)); } #[test] #[should_panic] fn nested_rt() { let rt1 = rt(); let rt2 = rt(); rt1.block_on(async { rt2.block_on(async { "hello" }) }); } #...
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
321
380
tokio-rs/tokio:tokio/tests/rt_common.rs:10
} }); thread::spawn(move || { thread::sleep(Duration::from_millis(50)); assert_ok!(tx.send(())); }); assert_ok!(rx.await); }); } #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn complete_t...
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
361
420
tokio-rs/tokio:tokio/tests/rt_common.rs:11
} #[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn spawn_from_other_thread_idle() { let rt = rt(); let handle = rt.clone(); let (tx, rx) = oneshot::channel(); thread::spawn(move || { thread::sleep(Duration::from_millis(50)); ...
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
401
460
tokio-rs/tokio:tokio/tests/rt_common.rs:12
loop { yield_once().await; } }); assert_ok!(rx.await); }); } #[test] fn sleep_at_root() { let rt = rt(); let now = Instant::now(); let dur = Duration::from_millis(50); rt.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
441
500
tokio-rs/tokio:tokio/tests/rt_common.rs:13
assert!(now.elapsed() >= dur); } #[cfg(not(target_os="wasi"))] // Wasi does not support bind #[test] fn block_on_socket() { let rt = rt(); rt.block_on(async move { let (tx, rx) = oneshot::channel(); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap()...
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
481
540
tokio-rs/tokio:tokio/tests/rt_common.rs:14
#[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn spawn_blocking_from_blocking() { let rt = rt(); let out = rt.block_on(async move { let inner = assert_ok!(tokio::task::spawn_blocking(|| { tokio::task::spawn_blocking(|| "hello") })...
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
521
580
tokio-rs/tokio:tokio/tests/rt_common.rs:15
fn socket_from_blocking() { let rt = rt(); rt.block_on(async move { let 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 || { // use the futures' ...
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
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:16
}); let jh2 = thread::spawn(move || { rt2.block_on(async move { tx2.send(()).unwrap(); time::sleep(Duration::from_millis(5)).await; rx1.await.unwrap(); time::sleep(Duration::from_millis(5)).await; }); }); j...
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
601
660
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
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/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
fdc28bc883ac37bb49abdf5a48fe631d2bee71bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fdc28bc883ac37bb49abdf5a48fe631d2bee71bf/tokio/tests/rt_common.rs
681
740