Skip to content

Commit 28c9a14

Browse files
authored
metrics: rename injection_queue_depth to global_queue_depth (#6918)
1 parent 32e0b43 commit 28c9a14

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

tokio/src/runtime/metrics/runtime.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ impl RuntimeMetrics {
7171
}
7272

7373
/// Returns the number of tasks currently scheduled in the runtime's
74-
/// injection queue.
74+
/// global queue.
7575
///
7676
/// Tasks that are spawned or notified from a non-runtime thread are
77-
/// scheduled using the runtime's injection queue. This metric returns the
78-
/// **current** number of tasks pending in the injection queue. As such, the
77+
/// scheduled using the runtime's global queue. This metric returns the
78+
/// **current** number of tasks pending in the global queue. As such, the
7979
/// returned value may increase or decrease as new tasks are scheduled and
8080
/// processed.
8181
///
@@ -88,11 +88,11 @@ impl RuntimeMetrics {
8888
/// async fn main() {
8989
/// let metrics = Handle::current().metrics();
9090
///
91-
/// let n = metrics.injection_queue_depth();
92-
/// println!("{} tasks currently pending in the runtime's injection queue", n);
91+
/// let n = metrics.global_queue_depth();
92+
/// println!("{} tasks currently pending in the runtime's global queue", n);
9393
/// }
9494
/// ```
95-
pub fn injection_queue_depth(&self) -> usize {
95+
pub fn global_queue_depth(&self) -> usize {
9696
self.handle.inner.injection_queue_depth()
9797
}
9898

@@ -681,6 +681,13 @@ impl RuntimeMetrics {
681681
}
682682
}
683683

684+
/// Renamed to [`RuntimeMetrics::global_queue_depth`]
685+
#[deprecated = "Renamed to global_queue_depth"]
686+
#[doc(hidden)]
687+
pub fn injection_queue_depth(&self) -> usize {
688+
self.handle.inner.injection_queue_depth()
689+
}
690+
684691
/// Returns the number of tasks currently scheduled in the given worker's
685692
/// local queue.
686693
///

tokio/tests/rt_metrics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn num_alive_tasks() {
4747
}
4848

4949
#[test]
50-
fn injection_queue_depth_current_thread() {
50+
fn global_queue_depth_current_thread() {
5151
use std::thread;
5252

5353
let rt = current_thread();
@@ -60,11 +60,11 @@ fn injection_queue_depth_current_thread() {
6060
.join()
6161
.unwrap();
6262

63-
assert_eq!(1, metrics.injection_queue_depth());
63+
assert_eq!(1, metrics.global_queue_depth());
6464
}
6565

6666
#[test]
67-
fn injection_queue_depth_multi_thread() {
67+
fn global_queue_depth_multi_thread() {
6868
let rt = threaded();
6969
let metrics = rt.metrics();
7070

@@ -85,7 +85,7 @@ fn injection_queue_depth_multi_thread() {
8585

8686
let mut fail: Option<String> = None;
8787
for i in 0..10 {
88-
let depth = metrics.injection_queue_depth();
88+
let depth = metrics.global_queue_depth();
8989
if i != depth {
9090
fail = Some(format!("{i} is not equal to {depth}"));
9191
break;

0 commit comments

Comments
 (0)