mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
metrics: rename injection_queue_depth to global_queue_depth (#6918)
This commit is contained in:
@@ -71,11 +71,11 @@ impl RuntimeMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of tasks currently scheduled in the runtime's
|
/// Returns the number of tasks currently scheduled in the runtime's
|
||||||
/// injection queue.
|
/// global queue.
|
||||||
///
|
///
|
||||||
/// Tasks that are spawned or notified from a non-runtime thread are
|
/// Tasks that are spawned or notified from a non-runtime thread are
|
||||||
/// scheduled using the runtime's injection queue. This metric returns the
|
/// scheduled using the runtime's global queue. This metric returns the
|
||||||
/// **current** number of tasks pending in the injection queue. As such, the
|
/// **current** number of tasks pending in the global queue. As such, the
|
||||||
/// returned value may increase or decrease as new tasks are scheduled and
|
/// returned value may increase or decrease as new tasks are scheduled and
|
||||||
/// processed.
|
/// processed.
|
||||||
///
|
///
|
||||||
@@ -88,11 +88,11 @@ impl RuntimeMetrics {
|
|||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
/// let metrics = Handle::current().metrics();
|
/// let metrics = Handle::current().metrics();
|
||||||
///
|
///
|
||||||
/// let n = metrics.injection_queue_depth();
|
/// let n = metrics.global_queue_depth();
|
||||||
/// println!("{} tasks currently pending in the runtime's injection queue", n);
|
/// println!("{} tasks currently pending in the runtime's global queue", n);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn injection_queue_depth(&self) -> usize {
|
pub fn global_queue_depth(&self) -> usize {
|
||||||
self.handle.inner.injection_queue_depth()
|
self.handle.inner.injection_queue_depth()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,6 +681,13 @@ impl RuntimeMetrics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Renamed to [`RuntimeMetrics::global_queue_depth`]
|
||||||
|
#[deprecated = "Renamed to global_queue_depth"]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn injection_queue_depth(&self) -> usize {
|
||||||
|
self.handle.inner.injection_queue_depth()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the number of tasks currently scheduled in the given worker's
|
/// Returns the number of tasks currently scheduled in the given worker's
|
||||||
/// local queue.
|
/// local queue.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ fn num_alive_tasks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn injection_queue_depth_current_thread() {
|
fn global_queue_depth_current_thread() {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
let rt = current_thread();
|
let rt = current_thread();
|
||||||
@@ -60,11 +60,11 @@ fn injection_queue_depth_current_thread() {
|
|||||||
.join()
|
.join()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(1, metrics.injection_queue_depth());
|
assert_eq!(1, metrics.global_queue_depth());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn injection_queue_depth_multi_thread() {
|
fn global_queue_depth_multi_thread() {
|
||||||
let rt = threaded();
|
let rt = threaded();
|
||||||
let metrics = rt.metrics();
|
let metrics = rt.metrics();
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ fn injection_queue_depth_multi_thread() {
|
|||||||
|
|
||||||
let mut fail: Option<String> = None;
|
let mut fail: Option<String> = None;
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
let depth = metrics.injection_queue_depth();
|
let depth = metrics.global_queue_depth();
|
||||||
if i != depth {
|
if i != depth {
|
||||||
fail = Some(format!("{i} is not equal to {depth}"));
|
fail = Some(format!("{i} is not equal to {depth}"));
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user