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:21
while !flag_clone.load(SeqCst){ tokio::task::yield_now().await; cnt += 1; if cnt >= 10 { // yielded too many times; report failure and // sleep forever so that the `fail_t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
#[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
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
#[test] #[should_panic] #[cfg_attr(target_os = "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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
} 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
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
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(); let barrier = Arc::new(Barrier::new(3)); let barrie...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
// Drop the rt. Regardless of which task is dropped first, its destructor will wake the // other task. drop(rt); } #[cfg(not(target_os="wasi"))] // Wasi doesn't support UDP or bind() #[test] fn io_notify_while_shutting_down() { use tokio::net::UdpSocket; use std::sync::A...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
#[cfg(not(target_os="wasi"))] // Wasi does not support threads #[test] fn shutdown_timeout() { let (tx, rx) = oneshot::channel(); let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { tx.send(()).unwrap(); thread::sl...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
tokio::time::sleep(std::time::Duration::from_millis(100)).await; }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is currently ignored on Windows because of a // rust-lang issue in thread local storage destructors. // See https://githu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/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
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
fn local_set_client_server_block_on() { let rt = rt(); let (tx, rx) = mpsc::channel(); let local = task::LocalSet::new(); local.block_on(&rt, async move { client_server_local(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[cfg(not(targ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
use tokio::sync::mpsc; let rt = rt(); rt.block_on(async { let (send, mut recv) = mpsc::unbounded_channel(); // Send a bunch of messages. for _ in 0..1_000 { send.send(()).unwrap(); } poll_fn(|cx| { // At leas...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
tokio::task::unconstrained(poll_fn(|cx| { // All the responses should be ready. for _ in 0..1_000 { assert_eq!(recv.poll_recv(cx), Poll::Ready(Some(()))); } Ready(()) })).await; }); } #[cfg(tokio_unstable)]...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,241
1,300
tokio-rs/tokio:tokio/tests/rt_common.rs:33
use std::sync::atomic::{Ordering, AtomicBool}; use tokio::sync::mpsc; const NUM: usize = 100; let rt = rt(); let running = Arc::new(AtomicBool::new(true)); rt.block_on(async { let (spawned_tx, mut spawned_rx) = mpsc::unbounded_channel(); let mut tasks...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,281
1,340
tokio-rs/tokio:tokio/tests/rt_common.rs:34
for _ in 0..NUM { spawned_rx.recv().await.unwrap(); } // spawn another task and wait for it to complete let handle = task::spawn(async { for _ in 0..5 { // Yielding forces it back into the local queue. task::yie...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,321
1,380
tokio-rs/tokio:tokio/tests/rt_common.rs:35
let th = std::thread::spawn(move || { tx.send(()).unwrap(); for tx in txs.drain(..) { let _ = tx.send(()); } }); rx.recv().unwrap(); drop(rt); th.join().unwrap(); } } #[test] #[cfg_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,361
1,420
tokio-rs/tokio:tokio/tests/rt_common.rs:36
if self.by_ref { self.waker.take().unwrap().wake_by_ref(); } else { self.waker.take().unwrap().wake(); } let _ = self.done.send(true); } } std::thread_local! { static TL_DATA: RefCell<Option<...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/rt_common.rs
1,401
1,437
tokio-rs/tokio:tokio/tests/rt_common.rs:1
#![allow(unknown_lints, unexpected_cfgs)] #![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)* ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1
60
tokio-rs/tokio:tokio/tests/rt_common.rs:14
#[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
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/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 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
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
561
620
tokio-rs/tokio:tokio/tests/rt_common.rs:17
#[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_on concurrently let rt = rt(); let rt2 = rt.clone(); let (tx1, rx1) = oneshot::c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
// created, none of those threads ever yield due to being at capacity, so // 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))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:19
assert_eq!(dst, b"hello world"); }); assert_ok!(srv.await); assert_ok!(cli.await); }); } /// Tests that yielded tasks are not scheduled until **after** resource /// drivers are polled. /// /// The OS does not guarantee when I/O events are delivered, so t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
721
780
tokio-rs/tokio:tokio/tests/rt_common.rs:20
use std::sync::Barrier; let rt = rt(); let flag = Arc::new(AtomicBool::new(false)); let barrier = Arc::new(Barrier::new(NUM_WORKERS)); rt.block_on(async { // Make sure other workers cannot steal tasks #[allow(clippy::reversed_empty_ranges)] for _ in...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
761
820
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
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
801
860
tokio-rs/tokio:tokio/tests/rt_common.rs:22
#[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(target_os = "wasi", ignore = "Wasi does not support threads...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
#[should_panic] #[cfg_attr(target_os = "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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
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
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
impl<F: FnMut()> Drop for OnDrop<F> { fn drop(&mut self) { (self.0)() } } let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let barrier = Arc::new(Barrier::new(3)); let barrier1 = barrier.clone(); let barri...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
// other task. drop(rt); } #[cfg(not(target_os="wasi"))] // Wasi doesn't support UDP or bind() #[test] fn io_notify_while_shutting_down() { use tokio::net::UdpSocket; use std::sync::Arc; for _ in 1..10 { let runtime = rt(); runtime.block_on(asyn...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:28
}); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_secs(10_000)); } // This test is currently ignored on Windows because of a // rust-lang issue in thread local storage destructors. // See https://github.com/rust-lang/rust/issues/74875 #[test] #[cfg(not(windows))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
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
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
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()); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
let rt = rt(); rt.block_on(async { let (send, mut recv) = mpsc::unbounded_channel(); // Send a bunch of messages. for _ in 0..1_000 { send.send(()).unwrap(); } poll_fn(|cx| { // At least one response should return pen...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
// All the responses should be ready. for _ in 0..1_000 { assert_eq!(recv.poll_recv(cx), Poll::Ready(Some(()))); } Ready(()) })).await; }); } #[cfg(tokio_unstable)] #[test] fn coop_consume_budget() { let rt...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,241
1,300
tokio-rs/tokio:tokio/tests/rt_common.rs:33
use tokio::sync::mpsc; const NUM: usize = 100; let rt = rt(); let running = Arc::new(AtomicBool::new(true)); rt.block_on(async { let (spawned_tx, mut spawned_rx) = mpsc::unbounded_channel(); let mut tasks = vec![]; // Spawn a bunch of tasks that p...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,281
1,340
tokio-rs/tokio:tokio/tests/rt_common.rs:35
let th = std::thread::spawn(move || { tx.send(()).unwrap(); for tx in txs.drain(..) { let _ = tx.send(()); } }); rx.recv().unwrap(); drop(rt); th.join().unwrap(); } } #[test] #[cfg_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,361
1,420
tokio-rs/tokio:tokio/tests/rt_common.rs:36
self.waker.take().unwrap().wake_by_ref(); } else { self.waker.take().unwrap().wake(); } let _ = self.done.send(true); } } std::thread_local! { static TL_DATA: RefCell<Option<TLData>> = const { RefCell::new(None)...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_common.rs
1,401
1,436
tokio-rs/tokio:tokio/tests/rt_common.rs:3
fn rt() -> Arc<Runtime> { tokio::runtime::Builder::new_multi_thread() .worker_threads(1) .enable_all() .build() .unwrap() .into() } } } } #[test] fn send_sync_bound() { use to...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
27539ae3bdfd08b7503f4919fe13299537cc16fc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27539ae3bdfd08b7503f4919fe13299537cc16fc/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:17
#[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_on concurrently let rt = rt(); let rt2 = rt.clone(); let (tx1, rx1) = oneshot::c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
27539ae3bdfd08b7503f4919fe13299537cc16fc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27539ae3bdfd08b7503f4919fe13299537cc16fc/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
// This test hits an edge case on windows where more threads than cores are // created, none of those threads ever yield due to being at capacity, so // 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 so...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
27539ae3bdfd08b7503f4919fe13299537cc16fc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27539ae3bdfd08b7503f4919fe13299537cc16fc/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:20
use std::sync::atomic::{AtomicBool, Ordering::SeqCst}; use std::sync::Barrier; let rt = rt(); let flag = Arc::new(AtomicBool::new(false)); let barrier = Arc::new(Barrier::new(NUM_WORKERS)); rt.block_on(async { // Make sure other workers cannot steal tasks ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
761
820
tokio-rs/tokio:tokio/tests/rt_common.rs:21
while !flag.load(SeqCst){ tokio::task::yield_now().await; cnt += 1; if cnt >= 10 { // yielded too many times; report failure and // sleep forever so that the `fail_test` b...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/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(target_os = "wasi", ignore = "Wasi does not support threads or panic recovery")] #[cfg(panic = "unwind")] #[test] fn panic_in_task() { let rt = rt(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
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| { if yielded { Poll::Ready(()) } else { yielded = true; cx....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
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(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
} } let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let barrier = Arc::new(Barrier::new(3)); let barrier1 = barrier.clone(); let barrier2 = barrier.clone(); let rt = rt(); rt.spawn(async move { let mut tx2 = Some(t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
#[cfg(not(target_os="wasi"))] // Wasi doesn't support UDP or bind() #[test] fn io_notify_while_shutting_down() { use tokio::net::UdpSocket; use std::sync::Arc; for _ in 1..10 { let runtime = rt(); runtime.block_on(async { let socket = UdpSocket::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
let runtime = rt(); runtime.block_on(async move { task::spawn_blocking(move || { tx.send(()).unwrap(); thread::sleep(Duration::from_secs(10_000)); }); rx.await.unwrap(); }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
// 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))] #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support threads")] fn runtime_in_thread_loca...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
}); let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind #[test] fn local_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:1
#![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] // Tests to run on both current-thread & 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
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/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
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
41
100
tokio-rs/tokio:tokio/tests/rt_common.rs:3
tokio::runtime::Builder::new_multi_thread() .worker_threads(1) .enable_all() .build() .unwrap() .into() } } } } #[test] fn send_sync_bound() { use tokio::runtime::Runtime; fn is_send<T: S...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
81
140
tokio-rs/tokio:tokio/tests/rt_common.rs:17
#[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_on concurrently let rt = rt(); let rt2 = rt.clone(); let (tx1, rx1) = oneshot::c...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
641
700
tokio-rs/tokio:tokio/tests/rt_common.rs:18
// created, none of those threads ever yield due to being at capacity, so // 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))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
681
740
tokio-rs/tokio:tokio/tests/rt_common.rs:20
use std::sync::Barrier; let rt = rt(); let flag = Arc::new(AtomicBool::new(false)); let barrier = Arc::new(Barrier::new(NUM_WORKERS)); rt.block_on(async { // Make sure other workers cannot steal tasks #[allow(clippy::reversed_empty_ranges)] for _ in...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
761
820
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
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/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(target_os = "wasi", ignore = "Wasi does not support threads or panic recovery")] #[cfg(panic = "unwind")] #[test] fn panic_in_task() { let rt = rt(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:23
} #[cfg(not(target_os="wasi"))] // Wasi does not support threads async fn yield_once() { let mut yielded = false; poll_fn(|cx| { if yielded { Poll::Ready(()) } else { yielded = true; cx.waker().wake_by_ref(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
881
940
tokio-rs/tokio:tokio/tests/rt_common.rs:24
Poll::Pending } } impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
} let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let barrier = Arc::new(Barrier::new(3)); let barrier1 = barrier.clone(); let barrier2 = barrier.clone(); let rt = rt(); rt.spawn(async move { let mut tx2 = Some(tx2); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
#[test] fn io_notify_while_shutting_down() { use tokio::net::UdpSocket; use std::sync::Arc; for _ in 1..10 { let runtime = rt(); runtime.block_on(async { let socket = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let addr = socket.lo...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:28
// 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))] #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support threads")] fn runtime_in_thread_loca...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind #[test] fn local_set_block_on_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
local.block_on(&rt, async move { client_server_local(tx).await }); assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind async fn client_server_local(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
// Send a bunch of messages. for _ in 0..1_000 { send.send(()).unwrap(); } poll_fn(|cx| { // At least one response should return pending. for _ in 0..1_000 { if recv.poll_recv(cx).is_pending() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
Ready(()) })).await; }); } #[cfg(tokio_unstable)] #[test] fn coop_consume_budget() { let rt = rt(); rt.block_on(async { poll_fn(|cx| { let counter = Arc::new(std::sync::Mutex::new(0)); let counter_clone = Arc::clone(&count...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,241
1,300
tokio-rs/tokio:tokio/tests/rt_common.rs:33
let running = Arc::new(AtomicBool::new(true)); rt.block_on(async { let (spawned_tx, mut spawned_rx) = mpsc::unbounded_channel(); let mut tasks = vec![]; // Spawn a bunch of tasks that ping-pong between each other to // saturate the runtime. for _ in ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,281
1,340
tokio-rs/tokio:tokio/tests/rt_common.rs:34
let handle = task::spawn(async { for _ in 0..5 { // Yielding forces it back into the local queue. task::yield_now().await; } }); handle.await.unwrap(); running.store(false, Ordering::Relaxed); for t i...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,321
1,380
tokio-rs/tokio:tokio/tests/rt_common.rs:35
}); rx.recv().unwrap(); drop(rt); th.join().unwrap(); } } #[test] #[cfg_attr(target_family = "wasm", ignore)] fn wake_by_ref_from_thread_local() { wake_from_thread_local(true); } #[test] #[cfg_attr(target_family = "wasm", ignore)] f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,361
1,420
tokio-rs/tokio:tokio/tests/rt_common.rs:36
} } std::thread_local! { static TL_DATA: RefCell<Option<TLData>> = const { RefCell::new(None) }; }; let (send, recv) = channel(); std::thread::spawn(move || { let rt = rt(); rt.block_on(rt.spawn(poll_fn(move |cx| { let waker ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
3936ebdfe4f44eda5630a9b461bbbc9976e5542c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/rt_common.rs
1,401
1,431
tokio-rs/tokio:tokio/tests/rt_common.rs:27
runtime.block_on(async move { task::spawn_blocking(move || { tx.send(()).unwrap(); thread::sleep(Duration::from_secs(10_000)); }); rx.await.unwrap(); }); Arc::try_unwrap(runtime).unwrap().shutdown_timeout(Duration::from_millis(100)); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2e5773a6fef7444e8959a992c7ed7d32f97af284
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2e5773a6fef7444e8959a992c7ed7d32f97af284/tokio/tests/rt_common.rs
1,041
1,100
tokio-rs/tokio:tokio/tests/rt_common.rs:28
// 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))] #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support threads")] fn runtime_in_thread_loca...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2e5773a6fef7444e8959a992c7ed7d32f97af284
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2e5773a6fef7444e8959a992c7ed7d32f97af284/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:35
}); rx.recv().unwrap(); drop(rt); th.join().unwrap(); } } #[test] #[cfg_attr(target_family = "wasm", ignore)] fn wake_by_ref_from_thread_local() { wake_from_thread_local(true); } #[test] #[cfg_attr(target_family = "wasm", ignore)] f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2e5773a6fef7444e8959a992c7ed7d32f97af284
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2e5773a6fef7444e8959a992c7ed7d32f97af284/tokio/tests/rt_common.rs
1,361
1,420
tokio-rs/tokio:tokio/tests/rt_common.rs:36
} } std::thread_local! { static TL_DATA: RefCell<Option<TLData>> = RefCell::new(None); }; let (send, recv) = channel(); std::thread::spawn(move || { let rt = rt(); rt.block_on(rt.spawn(poll_fn(move |cx| { let waker = cx.waker...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
2e5773a6fef7444e8959a992c7ed7d32f97af284
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2e5773a6fef7444e8959a992c7ed7d32f97af284/tokio/tests/rt_common.rs
1,401
1,431
tokio-rs/tokio:tokio/tests/rt_common.rs:34
let handle = task::spawn(async { for _ in 0..5 { // Yielding forces it back into the local queue. task::yield_now().await; } }); handle.await.unwrap(); running.store(false, Ordering::Relaxed); for t i...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
cc86fef9c0d09a688b273c114bb3ad64c40df462
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cc86fef9c0d09a688b273c114bb3ad64c40df462/tokio/tests/rt_common.rs
1,321
1,369
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
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/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(target_os = "wasi", ignore = "Wasi does not support threads or panic recovery")] #[test] fn panic_in_task() { let rt = rt(); let (tx, rx) = oneshot::...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
841
900
tokio-rs/tokio:tokio/tests/rt_common.rs:24
} } impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let barrier = Arc::new(Barrier::new(3)); let barrier1 = barrier.clone(); let barrier2 = barrier.clone(); let rt = rt(); rt.spawn(async move { let mut tx2 = Some(tx2); let ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:28
// rust-lang issue in thread local storage destructors. // See https://github.com/rust-lang/rust/issues/74875 #[test] #[cfg(not(windows))] #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support threads")] fn runtime_in_thread_local() { use std::cell::RefCell; use std::thread;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,081
1,140
tokio-rs/tokio:tokio/tests/rt_common.rs:29
let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind #[test] fn local_set_block_on_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,121
1,180
tokio-rs/tokio:tokio/tests/rt_common.rs:30
assert_ok!(rx.try_recv()); assert_err!(rx.try_recv()); } #[cfg(not(target_os = "wasi"))] // Wasi does not support bind async fn client_server_local(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); // Get the assigned address let addr ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
// Send a bunch of messages. for _ in 0..1_000 { send.send(()).unwrap(); } poll_fn(|cx| { // At least one response should return pending. for _ in 0..1_000 { if recv.poll_recv(cx).is_pending() { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
})).await; }); } #[cfg(tokio_unstable)] #[test] fn coop_consume_budget() { let rt = rt(); rt.block_on(async { poll_fn(|cx| { let counter = Arc::new(std::sync::Mutex::new(0)); let counter_clone = Arc::clone(&counter); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,241
1,300
tokio-rs/tokio:tokio/tests/rt_common.rs:33
let running = Arc::new(AtomicBool::new(true)); rt.block_on(async { let (spawned_tx, mut spawned_rx) = mpsc::unbounded_channel(); let mut tasks = vec![]; // Spawn a bunch of tasks that ping-pong between each other to // saturate the runtime. for _ in ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,281
1,340
tokio-rs/tokio:tokio/tests/rt_common.rs:34
for _ in 0..5 { // Yielding forces it back into the local queue. task::yield_now().await; } }); handle.await.unwrap(); running.store(false, Ordering::Relaxed); for t in tasks { t.await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
52e65102154cbbd49c3af4e6d208609476cdfdb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52e65102154cbbd49c3af4e6d208609476cdfdb4/tokio/tests/rt_common.rs
1,321
1,368
tokio-rs/tokio:tokio/tests/rt_common.rs:24
} } impl Drop for Never { fn drop(&mut self) { self.drop_tx.send(()).unwrap(); } } let rt = rt(); let (drop_tx, drop_rx) = mpsc::channel(); let (run_tx, run_rx) = oneshot::channel(); rt.block_on(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
921
980
tokio-rs/tokio:tokio/tests/rt_common.rs:25
fn drop(&mut self) { (self.0)() } } let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); let (tx3, rx3) = oneshot::channel(); let barrier = Arc::new(Barrier::new(4)); let barrier1 = barrier.clone(); let barrier2 =...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
961
1,020
tokio-rs/tokio:tokio/tests/rt_common.rs:26
}); rt.spawn(async move { let _ = tokio::join!(rx3, barrier3.wait()); // We'll never get here, but once task 3 drops, this will // force task 2 to re-schedule since it's waiting on oneshot 2. tx2.send(()).unwrap(); }); // Wait until every oneshot...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,001
1,060
tokio-rs/tokio:tokio/tests/rt_common.rs:27
}); tokio::spawn(async move { let buf = [0]; loop { send_half.send_to(&buf, &addr).await.unwrap(); tokio::time::sleep(Duration::from_millis(1)).await; } }); tokio...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,041
1,100
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
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/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
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/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(target_os =...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,161
1,220
tokio-rs/tokio:tokio/tests/rt_common.rs:31
}); let mut client = TcpStream::connect(&addr).await.unwrap(); let mut buf = vec![]; client.read_to_end(&mut buf).await.unwrap(); assert_eq!(buf, b"hello"); tx.send(()).unwrap(); } #[test] fn coop() { use std::task::Poll::Ready; use tokio::sync::mp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,201
1,260
tokio-rs/tokio:tokio/tests/rt_common.rs:32
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_000 { send.send(()).unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,241
1,300
tokio-rs/tokio:tokio/tests/rt_common.rs:33
}); // Assert that the worker was yielded and it didn't manage // to finish the whole work (assuming the total budget of 128) assert!(Pin::new(&mut worker).poll(cx).is_pending()); assert!(*counter_clone.lock().unwrap() < 1000); std::task::P...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,281
1,340
tokio-rs/tokio:tokio/tests/rt_common.rs:34
rx2.recv().await.unwrap(); } // Close the channel and wait for the other task to exit. drop(tx1); assert!(rx2.recv().await.is_none()); })); tasks.push(task::spawn(async move { while rx1....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,321
1,380
tokio-rs/tokio:tokio/tests/rt_common.rs:35
let rt = rt(); let mut txs = vec![]; for _ in 0..NUM_TASKS { let (tx, rx) = tokio::sync::oneshot::channel(); txs.push(tx); rt.spawn(async move { rx.await.unwrap(); }); } // Prime the ta...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_common.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_common.rs
1,361
1,389
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
4165601b1bbaa7c29cbfb319fe75a9adddf4085e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_common.rs
1
60