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_metrics.rs:6 | assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_local_schedule_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
tokio::spawn(async {}).await.unwrap();
});
drop(rt);
assert_eq!(1, metrics.worker_local_schedule_count(0)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ec66a92b016914f2ead483bada32ffe696a2fd3a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7 | let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
// First, we need to block the other worker until all tasks have
// b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ec66a92b016914f2ead483bada32ffe696a2fd3a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8 | use std::thread;
let rt = current_thread();
let handle = rt.handle().clone();
let metrics = rt.metrics();
thread::spawn(move || {
handle.spawn(async {});
})
.join()
.unwrap();
assert_eq!(1, metrics.injection_queue_depth());
let rt = threaded();
let handle = rt.handle(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ec66a92b016914f2ead483bada32ffe696a2fd3a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | fn worker_local_queue_depth() {
const N: usize = 100;
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ec66a92b016914f2ead483bada32ffe696a2fd3a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | .sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(metrics.io_driver_fd_r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ec66a92b016914f2ead483bada32ffe696a2fd3a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs | 361 | 417 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | assert_eq!(metrics.io_driver_ready_count(), 1);
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ec66a92b016914f2ead483bada32ffe696a2fd3a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs | 401 | 417 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | fn worker_local_queue_depth() {
const N: usize = 100;
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | .sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = current_thread();
let metrics = rt.metrics();
// Since this is enabled w/ the p... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_metrics.rs | 361 | 419 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | let _stream = rt.block_on(async move { stream.await.unwrap() });
assert_eq!(metrics.io_driver_ready_count(), 1);
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_metrics.rs | 401 | 419 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, not(tokio_wasi)))]
use tokio::runtime::Runtime;
use tokio::time::{self, Duration};
#[test]
fn num_workers() {
let rt = basic();
assert_eq!(1, rt.metrics().num_workers());
let rt = threaded();
assert_eq!(2, rt.metrics().num_worker... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | .join()
.unwrap();
rt.block_on(task).unwrap();
assert_eq!(1, rt.metrics().remote_schedule_count());
}
#[test]
fn worker_park_count() {
let rt = basic();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(2 <= ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(1 <= metrics.worker_noop_count(0));
assert!(1 <= metrics.worker_noop_count(1));
}
#[test]
fn worker_steal_count() {
// This metric only applies to ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | });
drop(rt);
let n: u64 = (0..metrics.num_workers())
.map(|i| metrics.worker_steal_count(i))
.sum();
assert_eq!(1, n);
}
#[test]
fn worker_poll_count() {
const N: u64 = 5;
let rt = basic();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5 | #[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = basic();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
tokio::task::yield_now().await;
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6 | assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_local_schedule_count() {
let rt = basic();
let metrics = rt.metrics();
rt.block_on(async {
tokio::spawn(async {}).await.unwrap();
});
drop(rt);
assert_eq!(1, metrics.worker_local_schedule_count(0));
as... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7 | let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
// First, we need to block the other worker until all tasks have
// b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8 | use std::thread;
let rt = basic();
let handle = rt.handle().clone();
let metrics = rt.metrics();
thread::spawn(move || {
handle.spawn(async {});
})
.join()
.unwrap();
assert_eq!(1, metrics.injection_queue_depth());
let rt = threaded();
let handle = rt.handle().clone()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | fn worker_local_queue_depth() {
const N: usize = 100;
let rt = basic();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let metrics = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | .sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = basic();
let metrics = rt.metrics();
// Since this is enabled w/ the process dr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 361 | 419 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | let _stream = rt.block_on(async move { stream.await.unwrap() });
assert_eq!(metrics.io_driver_ready_count(), 1);
}
fn basic() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d48c4370ceead56b1846bf638474cd9536d0fe62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d48c4370ceead56b1846bf638474cd9536d0fe62/tokio/tests/rt_metrics.rs | 401 | 419 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | .sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = basic();
let metrics = rt.metrics();
// Since this is enabled w/ the process dr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/rt_metrics.rs | 361 | 419 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | let _stream = rt.block_on(async move { stream.await.unwrap() });
assert_eq!(metrics.io_driver_ready_count(), 2);
}
fn basic() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/rt_metrics.rs | 401 | 419 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))]
use tokio::runtime::Runtime;
use tokio::time::{self, Duration};
#[test]
fn num_workers() {
let rt = basic();
assert_eq!(1, rt.metrics().num_workers());
let rt = threaded();
assert_eq!(2, rt.metrics().nu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]
use tokio::runtime::Runtime;
use tokio::time::{self, Duration};
#[test]
fn num_workers() {
let rt = basic();
assert_eq!(1, rt.metrics().num_workers());
let rt = threaded();
assert_eq!(2, rt.metrics().num_workers());
}
#[test]
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | f26ce08f37d8c8426736412f7aca51f4f39d43d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f26ce08f37d8c8426736412f7aca51f4f39d43d3/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(1 <= metrics.worker_noop_count(0));
assert!(1 <= metrics.worker_noop_count(1));
}
#[test]
fn worker_steal_count() {
// This metric only applies to ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 769fb1547fc50406fc2adb23cdf17a1aaf5744ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/769fb1547fc50406fc2adb23cdf17a1aaf5744ac/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | fn worker_local_queue_depth() {
const N: usize = 100;
let rt = basic();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let metrics = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 24f4ee31f0266a97547a81f510726da9c1bb9ec9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24f4ee31f0266a97547a81f510726da9c1bb9ec9/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | .sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
fn basic() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 24f4ee31f0266a97547a81f510726da9c1bb9ec9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24f4ee31f0266a97547a81f510726da9c1bb9ec9/tokio/tests/rt_metrics.rs | 361 | 385 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery
#![cfg(panic = "unwind")]
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().worker_threads(0).build(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_panic.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:3 | Ok(())
}
#[test]
fn builder_event_interval_interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().event_interval(0).build();
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(),... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_panic.rs | 81 | 114 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().worker_threads(0).build(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | df73fa21884f65ac4f5556ec72814cefed94897f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df73fa21884f65ac4f5556ec72814cefed94897f/tokio/tests/rt_panic.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:3 | Ok(())
}
#[test]
fn builder_event_interval_interval_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().event_interval(0).build();
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(),... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | df73fa21884f65ac4f5556ec72814cefed94897f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df73fa21884f65ac4f5556ec72814cefed94897f/tokio/tests/rt_panic.rs | 81 | 102 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().worker_threads(0).build(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/tests/rt_panic.rs | 41 | 90 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:3 | Ok(())
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 328a02c1ce08df6e888b19c81cc81d59422af5ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/328a02c1ce08df6e888b19c81cc81d59422af5ef/tokio/tests/rt_panic.rs | 81 | 90 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | });
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().worker_threads(0).build(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/rt_panic.rs | 41 | 78 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[cfg(panic = "unwind")]
#[test]
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | });
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[cfg(panic = "unwind")]
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/tests/rt_panic.rs | 41 | 81 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn current_handle_panic_c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().worker_threads(0).build();
})... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_panic.rs | 41 | 77 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn current_handle_panic_caller() ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn current_handle_panic_caller() ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().worker_threads(0).build();
})... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/rt_panic.rs | 41 | 77 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn current_handle_panic_c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future;
use std::error::Error;
use tokio::runtime::{Builder, Handle, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn current_handle_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = te... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | b51aa8f6f9cb205a8444743429cc80a86f982f1d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b51aa8f6f9cb205a8444743429cc80a86f982f1d/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future;
use parking_lot::{const_mutex, Mutex};
use std::error::Error;
use std::panic;
use std::sync::Arc;
use tokio::runtime::{Builder, Handle, Runtime};
fn test_panic<Func: FnOnce() + panic::UnwindSafe>(func: Func) -> Option<String> {
static PANIC... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/tests/rt_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:2 | #[test]
fn current_handle_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Handle::current();
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn into_panic_panic_caller() ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/tests/rt_panic.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_panic.rs:3 | // The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
fn builder_max_blocking_threads_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = Builder::new_multi_thread().max_blocking_threads(0).bui... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_panic.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/tests/rt_panic.rs | 81 | 105 |
tokio-rs/tokio:tokio/tests/rt_poll_callbacks.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![cfg(tokio_unstable)]
use std::sync::{atomic::AtomicUsize, Arc, Mutex};
use tokio::task::yield_now;
#[cfg(not(target_os = "wasi"))]
#[test]
fn callbacks_fire_multi_thread() {
let poll_start_counter = Arc::new(AtomicUsize::new(0));
let poll_stop_counter = Arc::new(A... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_poll_callbacks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_poll_callbacks.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_poll_callbacks.rs:2 | let task = rt.spawn(async {
yield_now().await;
yield_now().await;
yield_now().await;
});
let spawned_task_id = task.id();
rt.block_on(task).expect("task should succeed");
// We need to drop the runtime to guarantee the workers have exited (and thus called the callback)
drop... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_poll_callbacks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_poll_callbacks.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_poll_callbacks.rs:3 | let before_task_poll_callback_task_id: Arc<Mutex<Option<tokio::task::Id>>> =
Arc::new(Mutex::new(None));
let after_task_poll_callback_task_id: Arc<Mutex<Option<tokio::task::Id>>> =
Arc::new(Mutex::new(None));
let before_task_poll_callback_task_id_ref = Arc::clone(&before_task_poll_callback_task... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_poll_callbacks.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_poll_callbacks.rs | 81 | 128 |
tokio-rs/tokio:tokio/tests/rt_shutdown_err.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(miri))] // No socket in miri.
use std::io;
use tokio::net::TcpListener;
use tokio::runtime::Builder;
fn rt() -> tokio::runtime::Runtime {
Builder::new_current_thread().enable_all().build().unwrap()
}
#[test]
fn test_is_rt_shutdown_err() {
let rt... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_shutdown_err.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_shutdown_err.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_shutdown_err.rs:2 | fn test_join_error_panic() {
let rt = rt();
let handle = rt.spawn(async {
panic!("oops");
});
let join_err = rt.block_on(handle).unwrap_err();
let io_err: io::Error = join_err.into();
assert!(!tokio::runtime::is_rt_shutdown_err(&io_err));
}
#[test]
fn test_join_error_cancelled() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_shutdown_err.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_shutdown_err.rs | 41 | 82 |
tokio-rs/tokio:tokio/tests/rt_spawn_blocking.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
use std::time::Duration;
use tokio::runtime::Builder;
use tokio::sync::mpsc;
use tokio::task::JoinSet;
#[test]
fn issue_8056_regression_test() {
type Senders = Vec<mpsc::Sender<()>>;
type Handles = JoinSet<()>;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_spawn_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_spawn_blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_spawn_blocking.rs:2 | // task to the queue, it chose between "wake an idle worker" and "spawn a
// new worker", by reading the `num_idle_threads` `AtomicUsize`. The
// `num_idle_threads` counter was incremented by a worker before it calls
// `wait_for_task`, and was deremented after `Inner::run` after
// `wait_for_task` had ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_spawn_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_spawn_blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_spawn_blocking.rs:3 | quick().await;
let (persistent_senders, persistent_handles) = make_writer();
for _ in 0..2 {
quick().await;
quick().await;
let (senders, mut handles) = make_writer();
drop(senders);
while... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_spawn_blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_spawn_blocking.rs | 81 | 107 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.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_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:2 | tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
drop(rt);
}
}
#[test]
fn many_multishot_futures() {
use tokio::sync::mpsc;
const CHAIN: usize = 200;
const CYCLES: usize = 5;
const TRACKS: usize = 50;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:3 | // 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 {
let msg = chain_rx.recv().await.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:4 | 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_recv());
}
async fn client_server(tx: mpsc::Sender<()>) {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:5 | #[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 Never {
type ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:6 | 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!(a, b);
// Assert that the future was dropped
let c = num_drop.load(R... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:7 | });
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() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:8 | let num = cnt.fetch_add(1, Relaxed) + 1;
if num == NUM {
tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
block.wait();
}
}
#[test]
fn multi_threadpool() {
use tokio::sync::onesh... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/tests/rt_thread_pool.rs | 281 | 320 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:7 | });
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() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | d5c1119c881c9a8b511aa9000fd26b9bda014256 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d5c1119c881c9a8b511aa9000fd26b9bda014256/tokio/tests/rt_thread_pool.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.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_thread_pool.rs | MIT | 94f9b04b066cfc3da5c3ee2c961c21a9496135dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/94f9b04b066cfc3da5c3ee2c961c21a9496135dd/tokio/tests/rt_thread_pool.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:5 | #[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 Never {
type ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 94f9b04b066cfc3da5c3ee2c961c21a9496135dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/94f9b04b066cfc3da5c3ee2c961c21a9496135dd/tokio/tests/rt_thread_pool.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:6 | // 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!(a, b);
// Assert that the future was dropped
let c = num_drop.load(Relaxed);
as... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 94f9b04b066cfc3da5c3ee2c961c21a9496135dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/94f9b04b066cfc3da5c3ee2c961c21a9496135dd/tokio/tests/rt_thread_pool.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:7 | 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() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 94f9b04b066cfc3da5c3ee2c961c21a9496135dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/94f9b04b066cfc3da5c3ee2c961c21a9496135dd/tokio/tests/rt_thread_pool.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:8 | if num == NUM {
tx.send(()).unwrap();
}
});
}
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,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | 94f9b04b066cfc3da5c3ee2c961c21a9496135dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/94f9b04b066cfc3da5c3ee2c961c21a9496135dd/tokio/tests/rt_thread_pool.rs | 281 | 318 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:2 | tx.send(()).unwrap();
}
});
}
rx.recv().unwrap();
// Wait for the pool to shutdown
drop(rt);
}
}
#[test]
fn many_multishot_futures() {
use tokio::sync::mpsc;
const CHAIN: usize = 200;
const CYCLES: usize = 5;
const TRACKS: usize = 50;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | e19bd77ef0149b3141981b36f3ebc442fae4a0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e19bd77ef0149b3141981b36f3ebc442fae4a0b4/tokio/tests/rt_thread_pool.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:3 | // 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 {
let msg = chain_rx.recv().await.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | e19bd77ef0149b3141981b36f3ebc442fae4a0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e19bd77ef0149b3141981b36f3ebc442fae4a0b4/tokio/tests/rt_thread_pool.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:4 | 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_recv());
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | e19bd77ef0149b3141981b36f3ebc442fae4a0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e19bd77ef0149b3141981b36f3ebc442fae4a0b4/tokio/tests/rt_thread_pool.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:5 | }
#[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 Never {
ty... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | e19bd77ef0149b3141981b36f3ebc442fae4a0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e19bd77ef0149b3141981b36f3ebc442fae4a0b4/tokio/tests/rt_thread_pool.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:6 | // 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!(a, b);
// Assert that the future wa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | e19bd77ef0149b3141981b36f3ebc442fae4a0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e19bd77ef0149b3141981b36f3ebc442fae4a0b4/tokio/tests/rt_thread_pool.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:7 | });
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() {
// used for notifying the main thread
const NUM: usize = 1_000;
for _ in 0..10 {
let (tx, rx) = mpsc::channel(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | e19bd77ef0149b3141981b36f3ebc442fae4a0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e19bd77ef0149b3141981b36f3ebc442fae4a0b4/tokio/tests/rt_thread_pool.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:1 | #![warn(rust_2018_idioms)]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::Runtime;
use tokio::sync::oneshot;
use tokio::timer::delay;
use tokio_test::{assert_err, assert_ok};
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::{Duration, Inst... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | c8fdbed27a23321bb149a45aad5910d32c24be2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8fdbed27a23321bb149a45aad5910d32c24be2c/tokio/tests/rt_thread_pool.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:2 | is_send::<Runtime>();
}
#[test]
fn spawn_shutdown() {
let mut rt = Runtime::new().unwrap();
let (tx, rx) = mpsc::channel();
rt.block_on(async {
tokio::spawn(client_server(tx.clone()));
});
// Use spawner
rt.spawner().spawn(client_server(tx));
assert_ok!(rx.recv());
assert_ok!... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | c8fdbed27a23321bb149a45aad5910d32c24be2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8fdbed27a23321bb149a45aad5910d32c24be2c/tokio/tests/rt_thread_pool.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:3 | let (tx, rx) = oneshot::channel();
let mut listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
tokio::spawn(async move {
let _ = listener.accept().await;
tx.send(()).unwrap();
});
TcpStream::connect(&ad... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | c8fdbed27a23321bb149a45aad5910d32c24be2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8fdbed27a23321bb149a45aad5910d32c24be2c/tokio/tests/rt_thread_pool.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:4 | let mut rt = Runtime::new().unwrap();
let cnt = Arc::new(Mutex::new(0));
let (tx, rx) = mpsc::channel();
let tx = Arc::new(Mutex::new(tx));
let c = cnt.clone();
rt.block_on(async move {
for _ in 0..ITER {
let c = c.clone();
let tx = tx.clone();
tokio::sp... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | c8fdbed27a23321bb149a45aad5910d32c24be2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8fdbed27a23321bb149a45aad5910d32c24be2c/tokio/tests/rt_thread_pool.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_thread_pool.rs:5 | });
}
#[test]
fn after_start_and_before_stop_is_called() {
use std::sync::atomic::{AtomicUsize, Ordering};
let after_start = Arc::new(AtomicUsize::new(0));
let before_stop = Arc::new(AtomicUsize::new(0));
let after_inner = after_start.clone();
let before_inner = before_stop.clone();
let mut r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_thread_pool.rs | MIT | c8fdbed27a23321bb149a45aad5910d32c24be2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8fdbed27a23321bb149a45aad5910d32c24be2c/tokio/tests/rt_thread_pool.rs | 161 | 193 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:1 | #![warn(rust_2018_idioms)]
// Too slow on miri.
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok, assert_pending};
use std::fut... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:2 | 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.fetch_add(1, Relaxed) + 1;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_threaded.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.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:4 | }
});
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 = CYCLES;
rt.spawn(async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_threaded.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()
.enable_all()
.worker_threads(1)
.build()
.unwrap();
let (send, recv) = onesho... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_threaded.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.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_threaded.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.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_threaded.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.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:9 | assert!(before_stop.load(Ordering::Relaxed) > 0);
}
#[test]
// too slow on miri
#[cfg_attr(miri, ignore)]
fn blocking() {
// 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:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_threaded.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.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:11 | let rt = tokio::runtime::Builder::new_multi_thread()
// 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.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:12 | .await
})
.await
.unwrap();
});
}
#[test]
fn yield_after_block_in_place() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async move {
// Block in place then e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:13 | }
#[test]
#[should_panic]
fn max_blocking_threads_set_to_zero() {
let _rt = tokio::runtime::Builder::new_multi_thread()
.max_blocking_threads(0)
.build()
.unwrap();
}
/// Regression test for #6445.
///
/// After #6445, setting `global_queue_interval` to 1 is now technically valid.
/// This... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:14 | async fn hang_on_shutdown() {
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);
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:15 | impl Future for MyFuture {
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());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:16 | tokio::task::block_in_place(|| {});
}
#[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... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:17 | });
})
})
.await
.unwrap()
});
}
}
#[test]
fn yield_now_in_block_in_place() {
let rt = runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap();
rt.block_on(async {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:18 | tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async move {
for i in 0..(BUDGET + 1) {
let mut guard = lock.lock().await;
*guard = i;
}
});
})
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:19 | rx1.blocking_recv().unwrap();
});
})
};
// wait for the `block_in_place` to start
rx2.blocking_recv().unwrap();
// check that the deferred task was woken before the `block_in_place` ends
let is_woken = {
let lock = deffered_task.lock().unwrap();
lock.is_woken()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_threaded.rs:20 | if stall {
std::thread::sleep(Duration::from_micros(5));
}
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));
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_threaded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_threaded.rs | 761 | 820 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.