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_threaded.rs:4 | }
}
#[test]
fn spawn_shutdown() {
let mut rt = rt();
let (tx, rx) = mpsc::channel();
rt.block_on(async {
tokio::spawn(client_server(tx.clone()));
});
// Use spawner
rt.spawn(client_server(tx));
assert_ok!(rx.recv());
assert_ok!(rx.recv());
drop(rt);
assert_err!(rx.tr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:5 | client.read_to_end(&mut buf).await.unwrap();
assert_eq!(buf, b"hello");
tx.send(()).unwrap();
}
#[test]
fn drop_threadpool_drops_futures() {
for _ in 0..1_000 {
let num_inc = Arc::new(AtomicUsize::new(0));
let num_dec = Arc::new(AtomicUsize::new(0));
let num_drop = Arc::new(AtomicU... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:6 | })
.build()
.unwrap();
rt.spawn(Never(num_drop.clone()));
// Wait for the pool to shutdown
drop(rt);
// Assert that only a single thread was spawned.
let a = num_inc.load(Relaxed);
assert!(a >= 1);
// Assert that all threads shutdown
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:7 | })
.build()
.unwrap();
let (tx, rx) = oneshot::channel();
rt.spawn(async move {
assert_ok!(tx.send(()));
});
assert_ok!(rt.block_on(rx));
drop(rt);
assert!(after_start.load(Ordering::Relaxed) > 0);
assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
fn b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | }
block.wait();
for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.clone();
rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:9 | });
done_rx.recv().unwrap();
}
// When `block_in_place` returns, it attempts to reclaim the yielded runtime
// worker. In this case, the remainder of the task is on the runtime worker and
// must take part in the cooperative task budgeting system.
//
// The test ensures that, when this happens, attempting to cons... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:10 | // coop limit will be reached.
poll_fn(|cx| {
while let Poll::Ready(v) = {
tokio::pin! {
let fut = rx.recv();
}
Pin::new(&mut fut).poll(cx)
} {
if v.is_none() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | bff21aba6c1568f260fdf48d2eb3c0566e293f5a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/tests/rt_threaded.rs | 361 | 396 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{self, Runtime};
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::Atomic... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:2 | rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
drop(rt);
}
}
#[test]
fn many_multishot... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:3 | });
chain_rx = next_rx;
}
// This final task cycles if needed
let (mut final_tx, final_rx) = mpsc::channel(10);
let mut cycle_tx = start_tx.clone();
let mut rem = CYCLES;
rt.spawn(async move {
for _ in 0..CYCLES {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:4 | }
#[test]
fn spawn_shutdown() {
let mut rt = rt();
let (tx, rx) = mpsc::channel();
rt.block_on(async {
tokio::spawn(client_server(tx.clone()));
});
// Use spawner
rt.spawn(client_server(tx));
assert_ok!(rx.recv());
assert_ok!(rx.recv());
drop(rt);
assert_err!(rx.try_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:5 | assert_eq!(buf, b"hello");
tx.send(()).unwrap();
}
#[test]
fn drop_threadpool_drops_futures() {
for _ in 0..1_000 {
let num_inc = Arc::new(AtomicUsize::new(0));
let num_dec = Arc::new(AtomicUsize::new(0));
let num_drop = Arc::new(AtomicUsize::new(0));
struct Never(Arc<AtomicUsi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:6 | .build()
.unwrap();
rt.spawn(Never(num_drop.clone()));
// Wait for the pool to shutdown
drop(rt);
// Assert that only a single thread was spawned.
let a = num_inc.load(Relaxed);
assert!(a >= 1);
// Assert that all threads shutdown
let b = n... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:7 | .build()
.unwrap();
let (tx, rx) = oneshot::channel();
rt.spawn(async move {
assert_ok!(tx.send(()));
});
assert_ok!(rt.block_on(rx));
drop(rt);
assert!(after_start.load(Ordering::Relaxed) > 0);
assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
fn blocking() {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | block.wait();
for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.clone();
rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 281 | 337 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:9 | done_rx.recv().unwrap();
}
// Testing this does not panic
#[test]
fn max_threads() {
let _rt = tokio::runtime::Builder::new()
.threaded_scheduler()
.max_threads(1)
.build()
.unwrap();
}
fn rt() -> Runtime {
Runtime::new().unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 1bf1928088e5cc545eee447b38da7a785099059f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1bf1928088e5cc545eee447b38da7a785099059f/tokio/tests/rt_threaded.rs | 321 | 337 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | block.wait();
for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.clone();
rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b24ad9fe861ce01add2c6533149f643e38537f59 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b24ad9fe861ce01add2c6533149f643e38537f59/tokio/tests/rt_threaded.rs | 281 | 327 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{self, Runtime};
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::Atomic... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{self, Runtime};
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::AtomicUsize;
use std::sync::atom... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:2 | rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
drop(rt);
}
}
#[test]
fn many_multishot... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/rt_threaded.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:3 | chain_rx = next_rx;
}
// This final task cycles if needed
let (mut final_tx, final_rx) = mpsc::channel(10);
let mut cycle_tx = start_tx.clone();
let mut rem = CYCLES;
rt.spawn(async move {
for _ in 0..CYCLES {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/rt_threaded.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:4 | #[test]
fn spawn_shutdown() {
let mut rt = rt();
let (tx, rx) = mpsc::channel();
rt.block_on(async {
tokio::spawn(client_server(tx.clone()));
});
// Use spawner
rt.spawn(client_server(tx));
assert_ok!(rx.recv());
assert_ok!(rx.recv());
drop(rt);
assert_err!(rx.try_rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/rt_threaded.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:6 | .unwrap();
rt.spawn(Never(num_drop.clone()));
// Wait for the pool to shutdown
drop(rt);
// Assert that only a single thread was spawned.
let a = num_inc.load(Relaxed);
assert!(a >= 1);
// Assert that all threads shutdown
let b = num_dec.load(Relaxed);... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.clone();
rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
rx.recv().unwr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/tests/rt_threaded.rs | 281 | 326 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{self, Runtime};
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::AtomicUsize;
use std::sync::atom... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b1d9e55487d8411da89788ce0fbb3eb99a1f3a40 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1d9e55487d8411da89788ce0fbb3eb99a1f3a40/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:2 | let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
drop(rt);
}
}
#[test]
fn many_multishot_futures() {
use tokio::sync::mpsc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b1d9e55487d8411da89788ce0fbb3eb99a1f3a40 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1d9e55487d8411da89788ce0fbb3eb99a1f3a40/tokio/tests/rt_threaded.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:3 | chain_rx = next_rx;
}
// This final task cycles if needed
let (mut final_tx, final_rx) = mpsc::channel(10);
let mut cycle_tx = start_tx.clone();
let mut rem = CYCLES;
rt.spawn(async move {
for _ in 0..CYCLES {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b1d9e55487d8411da89788ce0fbb3eb99a1f3a40 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1d9e55487d8411da89788ce0fbb3eb99a1f3a40/tokio/tests/rt_threaded.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:5 | tx.send(()).unwrap();
}
#[test]
fn drop_threadpool_drops_futures() {
for _ in 0..1_000 {
let num_inc = Arc::new(AtomicUsize::new(0));
let num_dec = Arc::new(AtomicUsize::new(0));
let num_drop = Arc::new(AtomicUsize::new(0));
struct Never(Arc<AtomicUsize>);
impl Future for ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b1d9e55487d8411da89788ce0fbb3eb99a1f3a40 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1d9e55487d8411da89788ce0fbb3eb99a1f3a40/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:6 | rt.spawn(Never(num_drop.clone()));
// Wait for the pool to shutdown
drop(rt);
// Assert that only a single thread was spawned.
let a = num_inc.load(Relaxed);
assert!(a >= 1);
// Assert that all threads shutdown
let b = num_dec.load(Relaxed);
assert_eq!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b1d9e55487d8411da89788ce0fbb3eb99a1f3a40 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1d9e55487d8411da89788ce0fbb3eb99a1f3a40/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:8 | let tx = tx.clone();
rt.spawn(async move {
let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
block.wai... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | b1d9e55487d8411da89788ce0fbb3eb99a1f3a40 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b1d9e55487d8411da89788ce0fbb3eb99a1f3a40/tokio/tests/rt_threaded.rs | 281 | 323 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::future::{poll_fn, Future};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:2 | const NUM: usize = 1_000;
for _ in 0..5 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new(AtomicUsize::new(0));
for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.clone();
rt.spawn(async move {
let num = cnt.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:3 | assert_ok!(rx.await)
});
assert_eq!(out, "ZOMG");
cfg_metrics! {
let metrics = rt.metrics();
drop(rt);
assert_eq!(1, metrics.remote_schedule_count());
let mut local = 0;
for i in 0..metrics.num_workers() {
local += metrics.worker_local_schedule_count(i)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:4 | next_tx.send(v).await.unwrap();
}
});
chain_rx = next_rx;
}
// This final task cycles if needed
let (final_tx, final_rx) = tokio::sync::mpsc::channel(10);
let cycle_tx = start_tx.clone();
let mut rem = CYCL... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:5 | }
}
}
#[test]
fn lifo_slot_budget() {
async fn my_fn() {
spawn_another();
}
fn spawn_another() {
tokio::spawn(my_fn());
}
let rt = runtime::Builder::new_multi_thread_alt()
.enable_all()
.worker_threads(1)
.build()
.unwrap();
let (send, recv... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:6 | rt.spawn(client_server(tx));
assert_ok!(rx.recv());
assert_ok!(rx.recv());
drop(rt);
assert_err!(rx.try_recv());
}
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.loca... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:7 | struct Never(Arc<AtomicUsize>);
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.0.fetc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:8 | let b = num_dec.load(Relaxed);
assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
let after_start = Arc::new(AtomicUsize::n... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:9 | assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
fn blocking_task() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new(AtomicUsize::new(0));
// there are four work... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:10 | rx.recv().unwrap();
// Wait for the pool to shutdown
block.wait();
}
}
#[test]
fn multi_threadpool() {
use tokio::sync::oneshot;
let rt1 = rt();
let rt2 = rt();
let (tx, rx) = oneshot::channel();
let (done_tx, done_rx) = mpsc::channel();
rt2.spawn(async move {
rx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:11 | // runtime worker yielded as part of `block_in_place` and guarantees the
// same thread will reclaim the worker at the end of the
// `block_in_place` call.
.max_blocking_threads(1)
.build()
.unwrap();
rt.block_on(async move {
let (tx, mut rx) = tokio::sync::mpsc::cha... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:12 | .await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread_alt()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then enter a new runtime
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:13 | #[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread_alt()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically valid.
/// Thi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:14 | tokio::task::block_in_place(|| sync_rx.recv().ok());
});
tokio::spawn(async {
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
drop(sync_tx);
});
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
/// Demonstrates tokio-rs/tokio#3869
#[test]
fn wake_during_shutd... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:15 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self);
let mut lock = me.shared.lock().unwrap();
if me.put_waker {
lock.waker = Some(cx.waker().clone());
}
Poll::Pending
}
}
impl Drop ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:16 | #[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio::task::block_in_place(|| {});
}
#[should_panic]
#[tokio::main(flavor = "current_thread")]
#[test]
async fn test_block_in_place3() {
tokio::task::block_in_place(|| {});
}
#[tokio::main]
#[test]
async fn test_block_in_place4() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:17 | counter.fetch_add(1, Relaxed);
tokio::spawn(async move { iter(flag, counter, stall) });
}
}
let flag = Arc::new(AtomicBool::new(true));
let counter = Arc::new(AtomicUsize::new(61));
let interval = Arc::new(AtomicUsize::new(61));
{
let flag = flag.clone();
let co... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:18 | });
std::thread::yield_now();
}
}
flag.store(false, Relaxed);
let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again with a faster task
let flag = Arc::new(Ato... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:19 | }
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});
}
std::thr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_threaded_alt.rs | 721 | 744 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:2 | // used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..5 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new(AtomicUsize::new(0));
for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.clone();
rt.spawn(a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:3 | });
assert_ok!(rx.await)
});
assert_eq!(out, "ZOMG");
cfg_metrics! {
let metrics = rt.metrics();
drop(rt);
assert_eq!(1, metrics.remote_schedule_count());
let mut local = 0;
for i in 0..metrics.num_workers() {
local += metrics.worker_local_sche... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:4 | while let Some(v) = chain_rx.recv().await {
next_tx.send(v).await.unwrap();
}
});
chain_rx = next_rx;
}
// This final task cycles if needed
let (final_tx, final_rx) = tokio::sync::mpsc::channel(10);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:5 | });
}
}
}
#[test]
fn lifo_slot_budget() {
async fn my_fn() {
spawn_another();
}
fn spawn_another() {
tokio::spawn(my_fn());
}
let rt = runtime::Builder::new_multi_thread_alt()
.enable_all()
.worker_threads(1)
.build()
.unwrap();
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:7 | struct Never(Arc<AtomicUsize>);
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.0.fetc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:8 | // Assert that all threads shutdown
let b = num_dec.load(Relaxed);
assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:9 | assert!(after_start.load(Ordering::Relaxed) > 0);
assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
fn blocking_task() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:10 | }
rx.recv().unwrap();
// Wait for the pool to shutdown
block.wait();
}
}
#[test]
fn multi_threadpool() {
use tokio::sync::oneshot;
let rt1 = rt();
let rt2 = rt();
let (tx, rx) = oneshot::channel();
let (done_tx, done_rx) = mpsc::channel();
rt2.spawn(async move {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:11 | // Setting max threads to 1 prevents another thread from claiming the
// runtime worker yielded as part of `block_in_place` and guarantees the
// same thread will reclaim the worker at the end of the
// `block_in_place` call.
.max_blocking_threads(1)
.build()
.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:12 | })
.await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread_alt()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then enter a new ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:13 | #[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread_alt()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically valid.
/// Thi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:14 | tokio::spawn(async move {
tokio::task::block_in_place(|| sync_rx.recv().ok());
});
tokio::spawn(async {
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
drop(sync_tx);
});
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
/// Demonstrates tokio-rs/tokio... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:15 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self);
let mut lock = me.shared.lock().unwrap();
if me.put_waker {
lock.waker = Some(cx.waker().clone());
}
Poll::Pending
}
}
impl Drop ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:17 | counter.fetch_add(1, Relaxed);
tokio::spawn(async move { iter(flag, counter, stall) });
}
}
let flag = Arc::new(AtomicBool::new(true));
let counter = Arc::new(AtomicUsize::new(61));
let interval = Arc::new(AtomicUsize::new(61));
{
let flag = flag.clone();
let co... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:18 | interval.store(prev, Relaxed);
});
std::thread::yield_now();
}
}
flag.store(false, Relaxed);
let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::from_micros(500));
}
// Now, run it again wit... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:19 | break;
}
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/rt_threaded_alt.rs | 721 | 745 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:2 | fn many_oneshot_futures() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..5 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new(AtomicUsize::new(0));
for _ in 0..NUM {
let cnt = cnt.clone();
let tx = tx.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:3 | });
});
assert_ok!(rx.await)
});
assert_eq!(out, "ZOMG");
cfg_metrics! {
let metrics = rt.metrics();
drop(rt);
assert_eq!(1, metrics.remote_schedule_count());
let mut local = 0;
for i in 0..metrics.num_workers() {
local += metrics.worke... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:4 | rt.spawn(async move {
while let Some(v) = chain_rx.recv().await {
next_tx.send(v).await.unwrap();
}
});
chain_rx = next_rx;
}
// This final task cycles if needed
let (final_tx, final_rx)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:5 | }
});
}
}
}
#[test]
fn lifo_slot_budget() {
async fn my_fn() {
spawn_another();
}
fn spawn_another() {
tokio::spawn(my_fn());
}
let rt = runtime::Builder::new_multi_thread_alt()
.enable_all()
.worker_threads(1)
.build()
.unwr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:7 | let num_drop = Arc::new(AtomicUsize::new(0));
struct Never(Arc<AtomicUsize>);
impl Future for Never {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
Poll::Pending
}
}
impl Drop for Never {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:8 | // Assert that all threads shutdown
let b = num_dec.load(Relaxed);
assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:9 | assert!(after_start.load(Ordering::Relaxed) > 0);
assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
fn blocking_task() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
let rt = rt();
let cnt = Arc::new... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:10 | });
}
rx.recv().unwrap();
// Wait for the pool to shutdown
block.wait();
}
}
#[test]
fn multi_threadpool() {
use tokio::sync::oneshot;
let rt1 = rt();
let rt2 = rt();
let (tx, rx) = oneshot::channel();
let (done_tx, done_rx) = mpsc::channel();
rt2.spawn(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:11 | let rt = tokio::runtime::Builder::new_multi_thread_alt()
// Setting max threads to 1 prevents another thread from claiming the
// runtime worker yielded as part of `block_in_place` and guarantees the
// same thread will reclaim the worker at the end of the
// `block_in_place` call.
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:12 | .await
})
.await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread_alt()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place th... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:13 | }
#[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread_alt()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically valid.
/// ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:14 | let (sync_tx, sync_rx) = std::sync::mpsc::channel::<()>();
tokio::spawn(async move {
tokio::task::block_in_place(|| sync_rx.recv().ok());
});
tokio::spawn(async {
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
drop(sync_tx);
});
tokio::time::sleep(std::time::Du... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:15 | type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
let me = Pin::into_inner(self);
let mut lock = me.shared.lock().unwrap();
if me.put_waker {
lock.waker = Some(cx.waker().clone());
}
Poll::Pending
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:16 | }
#[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio::task::block_in_place(|| {});
}
#[should_panic]
#[tokio::main(flavor = "current_thread")]
#[test]
async fn test_block_in_place3() {
tokio::task::block_in_place(|| {});
}
#[tokio::main]
#[test]
async fn test_block_in_place4() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:17 | }
counter.fetch_add(1, Relaxed);
tokio::spawn(async move { iter(flag, counter, stall) });
}
}
let flag = Arc::new(AtomicBool::new(true));
let counter = Arc::new(AtomicUsize::new(61));
let interval = Arc::new(AtomicUsize::new(61));
{
let flag = flag.clone();... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:18 | let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});
std::thread::yield_now();
}
}
flag.store(false, Relaxed);
let w = Arc::downgrade(&interval);
drop(interval);
while w.strong_count() > 0 {
std::thread::sleep(Duration::f... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:19 | if n == 3 {
break;
}
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 29545d90370d925a7264ff8636013ee6bf1760e6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29545d90370d925a7264ff8636013ee6bf1760e6/tokio/tests/rt_threaded_alt.rs | 721 | 746 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use futures::future::poll_fn;
use st... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:12 | .await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread_alt()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then enter a new runtime
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:13 | #[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread_alt()
.max_blocking_threads(0)
.build()
.unwrap();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn hang_on_shutdown() {
let (sync_tx, sync_rx) = std... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:14 | put_waker: true,
};
let f2 = MyFuture {
shared,
put_waker: false,
};
(f1, f2)
}
}
impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:15 | rt.spawn(f1);
rt.spawn(f2);
rt.block_on(async { tokio::time::sleep(tokio::time::Duration::from_millis(20)).await });
}
#[should_panic]
#[tokio::test]
async fn test_block_in_place1() {
tokio::task::block_in_place(|| {});
}
#[tokio::test(flavor = "multi_thread")]
async fn test_block_in_place2() {
tokio... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:16 | use std::time::Duration;
let rt = runtime::Builder::new_multi_thread_alt()
.worker_threads(1)
.build()
.unwrap();
fn iter(flag: Arc<AtomicBool>, counter: Arc<AtomicUsize>, stall: bool) {
if flag.load(Relaxed) {
if stall {
std::thread::sleep(Duration:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:17 | // in one "good" value without being representative of reaching a good
// state.
if n == 3 {
break;
}
if Arc::strong_count(&interval) < 5_000 {
let counter = counter.clone();
let interval = interval.clone();
rt.spawn(async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:18 | // Now, hammer the injection queue until the interval reaches the expected range.
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
if curr <= 1_000 && curr > 32 {
n += 1;
} else {
n = 0;
}
if n == 3 {
break;
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 8832e936b1b86946ce802c5494bd8d575f8ba3a3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8832e936b1b86946ce802c5494bd8d575f8ba3a3/tokio/tests/rt_threaded_alt.rs | 681 | 717 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:8 | let b = num_dec.load(Relaxed);
assert_eq!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
assert_eq!(c, 1);
}
}
#[test]
fn start_stop_callbacks_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
let after_start = Arc::new(AtomicUsize::n... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_threaded_alt.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded_alt.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))]
#![cfg(tokio_unstable)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use futures::future::poll_fn;
use std::futur... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded_alt.rs | MIT | 4165601b1bbaa7c29cbfb319fe75a9adddf4085e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/tests/rt_threaded_alt.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_time_start_paused.rs:1 | #![cfg(feature = "full")]
use tokio::time::{Duration, Instant};
#[tokio::test(start_paused = true)]
async fn test_start_paused() {
let now = Instant::now();
// Pause a few times w/ std sleep and ensure `now` stays the same
for _ in 0..5 {
std::thread::sleep(Duration::from_millis(1));
asse... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_time_start_paused.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_time_start_paused.rs | 1 | 14 |
tokio-rs/tokio:tokio/tests/rt_time_start_paused.rs:1 | #![cfg(all(feature = "full"))]
use tokio::time::{Duration, Instant};
#[tokio::test(start_paused = true)]
async fn test_start_paused() {
let now = Instant::now();
// Pause a few times w/ std sleep and ensure `now` stays the same
for _ in 0..5 {
std::thread::sleep(Duration::from_millis(1));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_time_start_paused.rs | MIT | ee1c940709ad88f83daea29612a924524e37d173 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ee1c940709ad88f83daea29612a924524e37d173/tokio/tests/rt_time_start_paused.rs | 1 | 14 |
tokio-rs/tokio:tokio/tests/rt_unstable_eager_driver_handoff.rs:1 | // These tests only work on Unix platforms because they rely on Unix pipes
// as a way of generating I/O events from within the same process.
//
// Also, Miri doesn't like it when you leak a thread, which will happen in
// the "deadlock" case below, so we skip these tests on Miri.
#![cfg(all(not(miri), unix, feature = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_eager_driver_handoff.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_unstable_eager_driver_handoff.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_unstable_eager_driver_handoff.rs:3 | /// performed by the other task, which is waiting on an asynchronous event
/// before performing it. The task that blocks the runtime could, for example,
/// be waiting on a blocking syscall that completes only when the other task
/// does something.
fn do_test(rt: tokio::runtime::Runtime) -> Result<(), RecvTimeoutErro... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_eager_driver_handoff.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_unstable_eager_driver_handoff.rs | 81 | 140 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.