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_local.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]
use std::panic;
use tokio::runtime::LocalOptions;
use tokio::task::spawn_local;
use tokio::task::LocalSet;
#[test]
fn test_spawn_local_in_runtime() {
let rt = rt();
let res = rt.block_on(async move {
let (tx, rx) = tokio::sync:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_local.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_local.rs:2 | }
#[test]
fn test_spawn_local_on_runtime_object() {
let rt = rt();
let (tx, rx) = tokio::sync::oneshot::channel();
rt.spawn_local(async {
tokio::task::yield_now().await;
tx.send(5).unwrap();
});
let res = rt.block_on(async move { rx.await.unwrap() });
assert_eq!(res, 5);
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_local.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_local.rs:3 | std::thread::spawn(move || {
let rt = rt();
let handle = rt.handle().clone();
tx.send(handle).unwrap();
});
let handle = rx.recv().unwrap();
let _guard = handle.enter();
tokio::spawn(async {});
}
#[test]
#[should_panic = "Local tasks can only be spawned on a LocalRuntime fro... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_local.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_local.rs:4 | // `tokio::task::spawn_local` there. `std::panic::catch_unwind` is then used
// to capture the panic and to assert that it indeed occurs.
#[test]
#[cfg_attr(target_family = "wasm", ignore)] // threads not supported
fn test_spawn_local_panic() {
let rt = rt();
let local = LocalSet::new();
rt.block_on(local.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_local.rs | 121 | 170 |
tokio-rs/tokio:tokio/tests/rt_local.rs:5 | spawn_local(async {});
})
}
fn rt() -> tokio::runtime::LocalRuntime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build_local(LocalOptions::default())
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_local.rs | 161 | 170 |
tokio-rs/tokio:tokio/tests/rt_local.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]
use tokio::runtime::LocalOptions;
use tokio::task::spawn_local;
#[test]
fn test_spawn_local_in_runtime() {
let rt = rt();
let res = rt.block_on(async move {
let (tx, rx) = tokio::sync::oneshot::channel();
spawn_local(a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | d23a838732077122aee71530f15d3c0bf69f11bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d23a838732077122aee71530f15d3c0bf69f11bb/tokio/tests/rt_local.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_local.rs:2 | #[test]
fn test_spawn_local_on_runtime_object() {
let rt = rt();
let (tx, rx) = tokio::sync::oneshot::channel();
rt.spawn_local(async {
tokio::task::yield_now().await;
tx.send(5).unwrap();
});
let res = rt.block_on(async move { rx.await.unwrap() });
assert_eq!(res, 5);
}
#[t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | d23a838732077122aee71530f15d3c0bf69f11bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d23a838732077122aee71530f15d3c0bf69f11bb/tokio/tests/rt_local.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_local.rs:3 | let rt = rt();
let handle = rt.handle().clone();
tx.send(handle).unwrap();
});
let handle = rx.recv().unwrap();
let _guard = handle.enter();
tokio::spawn(async {});
}
#[test]
#[should_panic = "Local tasks can only be spawned on a LocalRuntime from the thread the runtime was created ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | d23a838732077122aee71530f15d3c0bf69f11bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d23a838732077122aee71530f15d3c0bf69f11bb/tokio/tests/rt_local.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_local.rs:4 | rt.block_on(async move {
spawn_local(async {});
})
}
#[test]
#[should_panic = "`spawn_local` called from outside of a `task::LocalSet` or `runtime::LocalRuntime`"]
fn test_spawn_local_in_multi_thread_runtime() {
let rt = tokio::runtime::Builder::new_multi_thread().build().unwrap();
rt.block_on(asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | d23a838732077122aee71530f15d3c0bf69f11bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d23a838732077122aee71530f15d3c0bf69f11bb/tokio/tests/rt_local.rs | 121 | 141 |
tokio-rs/tokio:tokio/tests/rt_local.rs:3 | let rt = rt();
let handle = rt.handle().clone();
tx.send(handle).unwrap();
});
let handle = rx.recv().unwrap();
let _guard = handle.enter();
tokio::spawn(async {});
}
#[test]
#[should_panic = "Local tasks can only be spawned on a LocalRuntime from the thread the runtime was created ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | 17d8c2b29d94550f504d8fd76d8d8aaf66095864 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17d8c2b29d94550f504d8fd76d8d8aaf66095864/tokio/tests/rt_local.rs | 81 | 119 |
tokio-rs/tokio:tokio/tests/rt_local.rs:2 | #[test]
fn test_spawn_local_on_runtime_object() {
let rt = rt();
let (tx, rx) = tokio::sync::oneshot::channel();
rt.spawn_local(async {
tokio::task::yield_now().await;
tx.send(5).unwrap();
});
let res = rt.block_on(async move { rx.await.unwrap() });
assert_eq!(res, 5);
}
#[t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_local.rs | 41 | 99 |
tokio-rs/tokio:tokio/tests/rt_local.rs:3 | let rt = rt();
let handle = rt.handle().clone();
tx.send(handle).unwrap();
});
let handle = rx.recv().unwrap();
let _guard = handle.enter();
spawn_local(async {});
}
fn rt() -> tokio::runtime::LocalRuntime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_local.rs | 81 | 99 |
tokio-rs/tokio:tokio/tests/rt_local.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]
use tokio::runtime::LocalOptions;
use tokio::task::spawn_local;
#[test]
fn test_spawn_local_in_runtime() {
let rt = rt();
let res = rt.block_on(async move {
let (tx, rx) = tokio::sync::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/tests/rt_local.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_local.rs:3 | std::thread::spawn(move || {
let rt = rt();
let handle = rt.handle().clone();
tx.send(handle).unwrap();
});
let handle = rx.recv().unwrap();
let _guard = handle.enter();
spawn_local(async {});
}
fn rt() -> tokio::runtime::LocalRuntime {
tokio::runtime::Builder::new_curre... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_local.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/tests/rt_local.rs | 81 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
use std::sync::mpsc;
use std::time::Duration;
use tokio::runtime::Runtime;
use tokio::time;
#[test]
fn num_workers() {
let rt = current_thread();
assert_eq!(1, rt.metrics().num_workers());
let rt ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | for _ in 0..100 {
if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn global_queue_depth_current_thread() {
use std::thread;
let rt = current_threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | }
panic!("exhausted every try to block the runtime");
}
#[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | drop(rt);
for i in 0..metrics.num_workers() {
assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_park_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5 | for _ in 0..100 {
if 1 <= metrics.worker_park_unpark_count(0) && 1 <= metrics.worker_park_unpark_count(1) {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(1, metrics.worker_park_unpark_count(0));
assert_eq!(1, metrics.worker_park_unpark_c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6 | task
})
.collect();
// Make sure the previously spawned tasks are blocking the runtime by
// receiving a message from each blocking task.
//
// If this times out we were unsuccessful in blocking the runtime and hit
// a deadlock instead (which might happen and is expected behaviour)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/rt_metrics.rs | 201 | 233 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | drop(rt);
for i in 0..metrics.num_workers() {
assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_park_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 0ce3a1188a56c4c133d5b789eb366c0752e9b22c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0ce3a1188a56c4c133d5b789eb366c0752e9b22c/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
use std::sync::mpsc;
use std::time::Duration;
use tokio::runtime::Runtime;
#[test]
fn num_workers() {
let rt = current_thread();
assert_eq!(1, rt.metrics().num_workers());
let rt = threaded();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn global_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = rt.h... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | panic!("exhausted every try to block the runtime");
}
#[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | drop(rt);
for i in 0..metrics.num_workers() {
assert!(zero < metrics.worker_total_busy_duration(i));
}
}
fn try_block_threaded(rt: &Runtime) -> Result<Vec<mpsc::Sender<()>>, mpsc::RecvTimeoutError> {
let (tx, rx) = mpsc::channel();
let blocking_tasks = (0..rt.metrics().num_workers())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/tests/rt_metrics.rs | 121 | 174 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5 | 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()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | afd3678f89dd0253af9194a4945711cfd3c0662a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/afd3678f89dd0253af9194a4945711cfd3c0662a/tokio/tests/rt_metrics.rs | 161 | 174 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn global_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = rt.h... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | panic!("exhausted every try to block the runtime");
}
fn try_block_threaded(rt: &Runtime) -> Result<Vec<mpsc::Sender<()>>, mpsc::RecvTimeoutError> {
let (tx, rx) = mpsc::channel();
let blocking_tasks = (0..rt.metrics().num_workers())
.map(|_| {
let tx = tx.clone();
let (task, b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_metrics.rs | 81 | 131 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | .build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/rt_metrics.rs | 121 | 131 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
use std::sync::mpsc;
use std::time::Duration;
use tokio::runtime::Runtime;
#[test]
fn num_workers() {
let rt = current_thread();
assert_eq!(1, rt.metrics().num... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 070a825999d3407f7c00e762fbecf298428e972a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/070a825999d3407f7c00e762fbecf298428e972a/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | for _ in 0..100 {
if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn global_queue_depth_current_thread() {
use std::thread;
let rt = current_threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 070a825999d3407f7c00e762fbecf298428e972a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/070a825999d3407f7c00e762fbecf298428e972a/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | }
panic!("exhausted every try to block the runtime");
}
fn try_block_threaded(rt: &Runtime) -> Result<Vec<mpsc::Sender<()>>, mpsc::RecvTimeoutError> {
let (tx, rx) = mpsc::channel();
let blocking_tasks = (0..rt.metrics().num_workers())
.map(|_| {
let tx = tx.clone();
let (... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 070a825999d3407f7c00e762fbecf298428e972a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/070a825999d3407f7c00e762fbecf298428e972a/tokio/tests/rt_metrics.rs | 81 | 132 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | .enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 070a825999d3407f7c00e762fbecf298428e972a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/070a825999d3407f7c00e762fbecf298428e972a/tokio/tests/rt_metrics.rs | 121 | 132 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | for _ in 0..100 {
if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn global_queue_depth_current_thread() {
use std::thread;
let rt = current_threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ce1c74f1cc1e31083744b6eb24b0e60ceaca4b4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce1c74f1cc1e31083744b6eb24b0e60ceaca4b4e/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | }
panic!("exhausted every try to block the runtime");
}
fn try_block_threaded(rt: &Runtime) -> Result<Vec<mpsc::Sender<()>>, mpsc::RecvTimeoutError> {
let (tx, rx) = mpsc::channel();
let blocking_tasks = (0..rt.metrics().num_workers())
.map(|_| {
let tx = tx.clone();
let (... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | ce1c74f1cc1e31083744b6eb24b0e60ceaca4b4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce1c74f1cc1e31083744b6eb24b0e60ceaca4b4e/tokio/tests/rt_metrics.rs | 81 | 132 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
use std::sync::{Arc, Barrier};
use tokio::runtime::Runtime;
#[test]
fn num_workers() {
let rt = current_thread();
assert_eq!(1, rt.metrics().num_workers());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 28c9a14a2e4da99842d41240b301022017b2a04a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28c9a14a2e4da99842d41240b301022017b2a04a/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn global_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = rt.h... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 28c9a14a2e4da99842d41240b301022017b2a04a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28c9a14a2e4da99842d41240b301022017b2a04a/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | });
}
barrier1.wait();
let mut fail: Option<String> = None;
for i in 0..10 {
let depth = metrics.global_queue_depth();
if i != depth {
fail = Some(format!("{i} is not equal to {depth}"));
break;
}
rt.spawn(async {});
}
barrier2.wait();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 28c9a14a2e4da99842d41240b301022017b2a04a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28c9a14a2e4da99842d41240b301022017b2a04a/tokio/tests/rt_metrics.rs | 81 | 116 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
use std::sync::{Arc, Barrier};
use tokio::runtime::Runtime;
#[test]
fn num_workers() {
let rt = current_thread();
assert_eq!(1, rt.metrics().num_workers());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 82628b8a7828507617a430e6875f1e25d5c211ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/82628b8a7828507617a430e6875f1e25d5c211ef/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn injection_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 82628b8a7828507617a430e6875f1e25d5c211ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/82628b8a7828507617a430e6875f1e25d5c211ef/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | });
}
barrier1.wait();
let mut fail: Option<String> = None;
for i in 0..10 {
let depth = metrics.injection_queue_depth();
if i != depth {
fail = Some(format!("{i} is not equal to {depth}"));
break;
}
rt.spawn(async {});
}
barrier2.wait()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 82628b8a7828507617a430e6875f1e25d5c211ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/82628b8a7828507617a430e6875f1e25d5c211ef/tokio/tests/rt_metrics.rs | 81 | 116 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | if rt.metrics().num_alive_tasks() == 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn injection_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | });
}
barrier1.wait();
for i in 0..10 {
assert_eq!(i, metrics.injection_queue_depth());
rt.spawn(async {});
}
barrier2.wait();
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_metrics.rs | 81 | 107 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
use tokio::runtime::Runtime;
#[test]
fn num_workers() {
let rt = current_thread();
assert_eq!(1, rt.metrics().num_workers());
let rt = threaded();
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_metrics.rs | 41 | 61 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | #[test]
fn num_idle_blocking_threads() {
let rt = current_thread();
assert_eq!(0, rt.metrics().num_idle_blocking_threads());
let _ = rt.block_on(rt.spawn_blocking(move || {}));
rt.block_on(async {
time::sleep(Duration::from_millis(5)).await;
});
// We need to wait until the blocking thr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | };
let h1 = rt.spawn_blocking(wait_until_ready.clone());
let h2 = rt.spawn_blocking(wait_until_ready);
assert!(rt.metrics().blocking_queue_depth() > 0);
drop(guard);
let _ = rt.block_on(h1);
let _ = rt.block_on(h2);
assert_eq!(0, rt.metrics().blocking_queue_depth());
}
#[test]
fn num_al... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | }
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_alive_tasks());
}
#[test]
fn spawned_tasks_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.spawned_tasks_count());
rt.block_on(rt.spawn(async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5 | })
})
.join()
.unwrap();
rt.block_on(task).unwrap();
assert_eq!(1, rt.metrics().remote_schedule_count());
let rt = threaded();
let handle = rt.handle().clone();
let task = thread::spawn(move || {
handle.spawn(async {
// DO nothing
})
})
.join()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6 | assert!(1 <= metrics.worker_park_count(0));
assert!(1 <= metrics.worker_park_count(1));
}
#[test]
fn worker_noop_count() {
// There isn't really a great way to generate no-op parks as they happen as
// false-positive events under concurrency.
let rt = current_thread();
let metrics = rt.metrics();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7 | // Move to the runtime.
tokio::spawn(async move {
// Spawn the task that sends to the channel
//
// Since the lifo slot is disabled, this task is stealable.
tokio::spawn(async move {
tx.send(()).unwrap();
});
// Blocking re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8 | }
});
drop(rt);
assert_eq!(N, metrics.worker_poll_count(0));
// Not currently supported for current-thread runtime
assert_eq!(Duration::default(), metrics.worker_mean_poll_time(0));
// Does not populate the histogram
assert!(!metrics.poll_count_histogram_enabled());
for i in 0..10 {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | }
}
#[test]
fn worker_poll_count_histogram() {
const N: u64 = 5;
let rts = [
tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | assert_eq!(num_buckets, 3);
let n = (0..num_workers)
.flat_map(|i| (0..num_buckets).map(move |j| (i, j)))
.map(|(worker, bucket)| metrics.poll_count_histogram_bucket_count(worker, bucket))
.sum();
assert_eq!(N, n);
}
}
#[test]
fn worker_poll_count_histogram_rang... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | let a = Duration::from_nanos(50000_u64.next_power_of_two());
let b = a * 2;
assert_eq!(metrics.poll_count_histogram_bucket_range(0), us(0)..a);
assert_eq!(metrics.poll_count_histogram_bucket_range(1), a..b);
assert_eq!(metrics.poll_count_histogram_bucket_range(2), b..max);
}
#[test]
fn worker_poll_cou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14 | // First, we need to block the other worker until all tasks have
// been spawned.
//
// We spawn from outside the runtime to ensure that the other worker
// will pick it up:
// <https://github.com/tokio-rs/tokio/issues/4730>
tokio::task::spawn_bloc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:15 | let handle = rt.handle().clone();
let metrics = rt.metrics();
thread::spawn(move || {
handle.spawn(async {});
})
.join()
.unwrap();
assert_eq!(1, metrics.injection_queue_depth());
}
#[test]
fn injection_queue_depth_multi_thread() {
let rt = threaded();
let metrics = rt.metrics... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:16 | #[test]
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();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:17 | .map(|i| metrics.worker_local_queue_depth(i))
.sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[test]
fn budget_exhaustion_yield() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metric... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18 | fn budget_exhaustion_yield_with_joins() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield_1 = false;
let mut did_yield_2 = false;
// block on a task which consumes budget until it yields
rt.block_on(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:19 | assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[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_registered_count(), 0);
let stream = tokio::net::TcpStream::connect... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:20 | .unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
}
fn threaded_no_lifo() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.disable_lifo_slot()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/68d0e3cb5fc0b5e4348e5eeab79e44fc91f0f2d4/tokio/tests/rt_metrics.rs | 761 | 783 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | #[test]
fn num_idle_blocking_threads() {
let rt = current_thread();
assert_eq!(0, rt.metrics().num_idle_blocking_threads());
let _ = rt.block_on(rt.spawn_blocking(move || {}));
rt.block_on(async {
time::sleep(Duration::from_millis(5)).await;
});
// We need to wait until the blocking thr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 341b5daa6e4592d285674de4eb116c928fc9f29c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | };
let h1 = rt.spawn_blocking(wait_until_ready.clone());
let h2 = rt.spawn_blocking(wait_until_ready);
assert!(rt.metrics().blocking_queue_depth() > 0);
drop(guard);
let _ = rt.block_on(h1);
let _ = rt.block_on(h2);
assert_eq!(0, rt.metrics().blocking_queue_depth());
}
#[test]
fn num_ac... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 341b5daa6e4592d285674de4eb116c928fc9f29c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | }
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert_eq!(0, rt.metrics().num_active_tasks());
}
#[test]
fn spawned_tasks_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.spawned_tasks_count());
rt.block_on(rt.spawn(async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 341b5daa6e4592d285674de4eb116c928fc9f29c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | #[test]
fn num_idle_blocking_threads() {
let rt = current_thread();
assert_eq!(0, rt.metrics().num_idle_blocking_threads());
let _ = rt.block_on(rt.spawn_blocking(move || {}));
rt.block_on(async {
time::sleep(Duration::from_millis(5)).await;
});
// We need to wait until the blocking thr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 2890d0c3db4f595330d8d223bfbfeb81e205b048 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2890d0c3db4f595330d8d223bfbfeb81e205b048/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | };
let h1 = rt.spawn_blocking(wait_until_ready.clone());
let h2 = rt.spawn_blocking(wait_until_ready);
assert!(rt.metrics().blocking_queue_depth() > 0);
drop(guard);
let _ = rt.block_on(h1);
let _ = rt.block_on(h2);
assert_eq!(0, rt.metrics().blocking_queue_depth());
}
#[test]
fn active... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | 2890d0c3db4f595330d8d223bfbfeb81e205b048 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2890d0c3db4f595330d8d223bfbfeb81e205b048/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(
feature = "full",
tokio_unstable,
not(target_os = "wasi"),
target_has_atomic = "64"
))]
use std::future::Future;
use std::sync::{Arc, Barrier, Mutex};
use std::task::Poll;
use tokio::macros::support::poll_fn;
use tokio::r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | rt.block_on(async {
time::sleep(Duration::from_millis(5)).await;
});
// We need to wait until the blocking thread has become idle. Usually 5ms is
// enough for this to happen, but not always. When it isn't enough, sleep
// for another second. We don't always wait for a whole second since we wan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | drop(guard);
let _ = rt.block_on(h1);
let _ = rt.block_on(h2);
assert_eq!(0, rt.metrics().blocking_queue_depth());
}
#[test]
fn active_tasks_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.active_tasks_count());
rt.spawn(async move {
assert_e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | rt.block_on(task).unwrap();
assert_eq!(1, rt.metrics().remote_schedule_count());
let rt = threaded();
let handle = rt.handle().clone();
let task = thread::spawn(move || {
handle.spawn(async {
// DO nothing
})
})
.join()
.unwrap();
rt.block_on(task).unwrap()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5 | fn worker_noop_count() {
// There isn't really a great way to generate no-op parks as they happen as
// false-positive events under concurrency.
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6 | // Since the lifo slot is disabled, this task is stealable.
tokio::spawn(async move {
tx.send(()).unwrap();
});
// Blocking receive on the channel.
rx.recv().unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7 | assert_eq!(Duration::default(), metrics.worker_mean_poll_time(0));
// Does not populate the histogram
assert!(!metrics.poll_count_histogram_enabled());
for i in 0..10 {
assert_eq!(0, metrics.poll_count_histogram_bucket_count(0, i));
}
let rt = threaded();
let metrics = rt.metrics();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8 | const N: u64 = 5;
let rts = [
tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.metrics_poll_count_histogram_buckets(3)
.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | .sum();
assert_eq!(N, n);
}
}
#[test]
fn worker_poll_count_histogram_range() {
let max = Duration::from_nanos(u64::MAX);
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::ru... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | assert_eq!(metrics.poll_count_histogram_bucket_range(1), a..b);
assert_eq!(metrics.poll_count_histogram_bucket_range(2), b..max);
}
#[test]
fn worker_poll_count_histogram_disabled_without_explicit_enable() {
let rts = [
tokio::runtime::Builder::new_current_thread()
.enable_all()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | for _ in 0..N {
tokio::spawn(async {
tokio::task::yield_now().await;
})
.await
.unwrap();
}
});
drop(rt);
assert!(zero < metrics.worker_total_busy_duration(0));
let rt = threaded();
let metrics = rt.metrics();
rt.block_o... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12 | drop(rt);
assert_eq!(1, metrics.worker_local_schedule_count(0));
assert_eq!(0, metrics.remote_schedule_count());
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
tokio::spawn(async {}).await.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13 | // will pick it up:
// <https://github.com/tokio-rs/tokio/issues/4730>
tokio::task::spawn_blocking(|| {
tokio::spawn(async move {
tx1.send(()).unwrap();
rx2.recv().unwrap();
});
});
rx1.recv().unwrap... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14 | })
.join()
.unwrap();
assert_eq!(1, metrics.injection_queue_depth());
}
#[test]
fn injection_queue_depth_multi_thread() {
let rt = threaded();
let metrics = rt.metrics();
let barrier1 = Arc::new(Barrier::new(3));
let barrier2 = Arc::new(Barrier::new(3));
// Spawn a task per runtime w... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18 | #[test]
fn io_driver_fd_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(metrics.io_driver_fd_registered_count(), 0);
let stream = tokio::net::TcpStream::connect("google.com:80");
let stream = rt.block_on(async move { stream.await.unwrap() });
assert_eq!(metrics.io_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 681 | 738 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:19 | .worker_threads(2)
.enable_all()
.build()
.unwrap()
}
fn threaded_no_lifo() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.disable_lifo_slot()
.enable_all()
.build()
.unwrap()
}
fn us(n: u64) -> Duration {
Duration::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | cba86cf1b1edea8cd131f168a99953e6e35739d2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cba86cf1b1edea8cd131f168a99953e6e35739d2/tokio/tests/rt_metrics.rs | 721 | 738 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))]
use std::future::Future;
use std::sync::{Arc, Barrier, Mutex};
use std::task::Poll;
use tokio::macros::support::poll_fn;
use tokio::runtime::Runtime;
use tokio::task::consume_bu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2 | // enough for this to happen, but not always. When it isn't enough, sleep
// for another second. We don't always wait for a whole second since we want
// the test suite to finish quickly.
//
// Note that the timeout for idle threads to be killed is 10 seconds.
if 0 == rt.metrics().num_idle_blocking_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3 | assert_eq!(0, rt.metrics().blocking_queue_depth());
}
#[test]
fn active_tasks_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.active_tasks_count());
rt.spawn(async move {
assert_eq!(1, metrics.active_tasks_count());
});
let rt = threaded();
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4 | let handle = rt.handle().clone();
let task = thread::spawn(move || {
handle.spawn(async {
// DO nothing
})
})
.join()
.unwrap();
rt.block_on(task).unwrap();
assert_eq!(1, rt.metrics().remote_schedule_count());
}
#[test]
fn worker_park_count() {
let rt = current... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5 | let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(0 < metrics.worker_noop_count(0));
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6 | // Blocking receive on the channel.
rx.recv().unwrap();
})
.await
.unwrap();
});
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_and_time() {
con... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7 | assert_eq!(0, metrics.poll_count_histogram_bucket_count(0, i));
}
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(task()).await.unwrap();
}
});
drop(rt);
// Account for the `block_on` task
let n = (0..metrics.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8 | .enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.metrics_poll_count_histogram_buckets(3)
.metrics_poll_count_histogram_resolution(Duration::from_millis(50))
.build()
.unwrap(),
tokio::r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9 | #[test]
fn worker_poll_count_histogram_range() {
let max = Duration::from_nanos(u64::MAX);
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.met... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10 | fn worker_poll_count_histogram_disabled_without_explicit_enable() {
let rts = [
tokio::runtime::Builder::new_current_thread()
.enable_all()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.metrics_poll_count_histogram_buckets(3)
.me... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11 | .unwrap();
}
});
drop(rt);
assert!(zero < metrics.worker_total_busy_duration(0));
let rt = threaded();
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 | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12 | let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
tokio::spawn(async {}).await.unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (0..metrics.num_workers())
.map(|i| met... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13 | rx2.recv().unwrap();
});
});
rx1.recv().unwrap();
// Spawn many tasks
for _ in 0..300 {
tokio::spawn(async {});
}
tx2.send(()).unwrap();
})
.await
.unwrap();
});
drop(rt);
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14 | }
#[test]
fn injection_queue_depth_multi_thread() {
let rt = threaded();
let metrics = rt.metrics();
let barrier1 = Arc::new(Barrier::new(3));
let barrier2 = Arc::new(Barrier::new(3));
// Spawn a task per runtime worker to block it.
for _ in 0..2 {
let barrier1 = barrier1.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:15 | assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async move {
// Move to the runtime
tokio::spawn(async move {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::chann... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:16 | }
#[test]
fn budget_exhaustion_yield() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield = false;
// block on a task which consumes budget until it yields
rt.block_on(poll_fn(|cx| loop {
if did_yield {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_metrics.rs:17 | rt.block_on(async {
tokio::join!(
poll_fn(|cx| loop {
if did_yield_1 {
return Poll::Ready(());
}
let fut = consume_budget();
tokio::pin!(fut);
if fut.poll(cx).is_pending() {
did_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_metrics.rs | MIT | d085260ee02f25c4a56cfcd9d0b57fa15840aebb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs | 641 | 700 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.