Skip to content

Commit

Permalink
Fix rustfmt errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matildasmeds committed Apr 16, 2023
1 parent 8f80feb commit 1a50d95
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
36 changes: 18 additions & 18 deletions tokio/src/runtime/metrics/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ impl RuntimeMetrics {
self.handle.inner.num_blocking_threads()
}

/// Returns the number of idle threads, which hve spawned by the runtime
/// for `spawn_blocking` calls.
/// Returns the number of active tasks in the runtime.
///
/// # Examples
///
Expand All @@ -78,21 +77,18 @@ impl RuntimeMetrics {
///
/// #[tokio::main]
/// async fn main() {
/// let _ = tokio::task::spawn_blocking(move || {
/// // Stand-in for compute-heavy work or using synchronous APIs
/// 1 + 1
/// }).await;
/// let metrics = Handle::current().metrics();
/// let metrics = Handle::current().metrics();
///
/// let n = metrics.num_idle_blocking_threads();
/// println!("Runtime has {} idle blocking thread pool threads", n);
/// let n = metrics.active_tasks_count();
/// println!("Runtime has {} active tasks", n);
/// }
/// ```
pub fn num_idle_blocking_threads(&self) -> usize {
self.handle.inner.num_idle_blocking_threads()
pub fn active_tasks_count(&self) -> usize {
self.handle.inner.active_tasks_count()
}

/// Returns the number of active tasks in the runtime.
/// Returns the number of idle threads, which hve spawned by the runtime
/// for `spawn_blocking` calls.
///
/// # Examples
///
Expand All @@ -101,14 +97,18 @@ impl RuntimeMetrics {
///
/// #[tokio::main]
/// async fn main() {
/// let metrics = Handle::current().metrics();
/// let _ = tokio::task::spawn_blocking(move || {
/// // Stand-in for compute-heavy work or using synchronous APIs
/// 1 + 1
/// }).await;
/// let metrics = Handle::current().metrics();
///
/// let n = metrics.active_tasks_count();
/// println!("Runtime has {} active tasks", n);
/// let n = metrics.num_idle_blocking_threads();
/// println!("Runtime has {} idle blocking thread pool threads", n);
/// }
/// ```
pub fn active_tasks_count(&self) -> usize {
self.handle.inner.active_tasks_count()
pub fn num_idle_blocking_threads(&self) -> usize {
self.handle.inner.num_idle_blocking_threads()
}

/// Returns the number of tasks scheduled from **outside** of the runtime.
Expand Down Expand Up @@ -689,4 +689,4 @@ cfg_net! {
.unwrap_or(0)
}
}
}
}
2 changes: 1 addition & 1 deletion tokio/src/runtime/scheduler/current_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,4 @@ impl Drop for CoreGuard<'_> {
self.scheduler.notify.notify_one()
}
}
}
}
2 changes: 1 addition & 1 deletion tokio/src/runtime/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ cfg_not_rt! {
panic!("{}", crate::util::error::CONTEXT_MISSING_ERROR)
}
}
}
}
2 changes: 1 addition & 1 deletion tokio/src/runtime/scheduler/multi_thread/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ impl fmt::Debug for Handle {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("multi_thread::Handle { ... }").finish()
}
}
}
2 changes: 1 addition & 1 deletion tokio/src/runtime/task/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,4 @@ mod tests {
last_id = next_id;
}
}
}
}

0 comments on commit 1a50d95

Please sign in to comment.