| 1 | use super::Handle; |
| 2 | |
| 3 | cfg_unstable_metrics! { |
| 4 | use crate::runtime::{SchedulerMetrics, WorkerMetrics}; |
| 5 | } |
| 6 | |
| 7 | impl Handle { |
| 8 | pub(crate) fn num_workers(&self) -> usize { |
| 9 | self.shared.worker_metrics.len() |
| 10 | } |
| 11 | |
| 12 | pub(crate) fn num_alive_tasks(&self) -> usize { |
| 13 | self.shared.owned.num_alive_tasks() |
| 14 | } |
| 15 | |
| 16 | pub(crate) fn injection_queue_depth(&self) -> usize { |
| 17 | self.shared.injection_queue_depth() |
| 18 | } |
| 19 | |
| 20 | cfg_unstable_metrics! { |
| 21 | cfg_64bit_metrics! { |
| 22 | pub(crate) fn spawned_tasks_count(&self) -> u64 { |
| 23 | self.shared.owned.spawned_tasks_count() |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | pub(crate) fn num_blocking_threads(&self) -> usize { |
| 28 | // workers are currently spawned using spawn_blocking |
| 29 | self.blocking_spawner |
| 30 | .num_threads() |
| 31 | .saturating_sub(self.num_workers()) |
| 32 | } |
| 33 | |
| 34 | pub(crate) fn num_idle_blocking_threads(&self) -> usize { |
| 35 | self.blocking_spawner.num_idle_threads() |
| 36 | } |
| 37 | |
| 38 | pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics { |
| 39 | &self.shared.scheduler_metrics |
| 40 | } |
| 41 | |
| 42 | pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics { |
| 43 | &self.shared.worker_metrics[worker] |
| 44 | } |
| 45 | |
| 46 | pub(crate) fn worker_local_queue_depth(&self, worker: usize) -> usize { |
| 47 | self.shared.worker_local_queue_depth(worker) |
| 48 | } |
| 49 | |
| 50 | pub(crate) fn blocking_queue_depth(&self) -> usize { |
| 51 | self.blocking_spawner.queue_depth() |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |