Skip to content

Commit

Permalink
rename active_tasks_count to num_active_tasks for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Apr 22, 2024
1 parent 10098c0 commit afe5b85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tokio/src/runtime/metrics/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ impl RuntimeMetrics {
/// async fn main() {
/// let metrics = Handle::current().metrics();
///
/// let n = metrics.active_tasks_count();
/// let n = metrics.num_active_tasks();
/// println!("Runtime has {} active tasks", n);
/// }
/// ```
pub fn active_tasks_count(&self) -> usize {
pub fn num_active_tasks(&self) -> usize {
self.handle.inner.active_tasks_count()
}

Expand Down
10 changes: 5 additions & 5 deletions tokio/tests/rt_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ fn blocking_queue_depth() {
}

#[test]
fn active_tasks_count() {
fn num_active_tasks() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.active_tasks_count());
assert_eq!(0, metrics.num_active_tasks());
rt.block_on(rt.spawn(async move {
assert_eq!(1, metrics.active_tasks_count());
assert_eq!(1, metrics.num_active_tasks());
}))
.unwrap();

let rt = threaded();
let metrics = rt.metrics();
assert_eq!(0, metrics.active_tasks_count());
assert_eq!(0, metrics.num_active_tasks());
rt.block_on(rt.spawn(async move {
assert_eq!(1, metrics.active_tasks_count());
assert_eq!(1, metrics.num_active_tasks());
}))
.unwrap();
}
Expand Down

0 comments on commit afe5b85

Please sign in to comment.