• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::loom::sync::atomic::{AtomicU64, Ordering::Relaxed};
2 
3 /// Retrieves metrics from the Tokio runtime.
4 ///
5 /// **Note**: This is an [unstable API][unstable]. The public API of this type
6 /// may break in 1.x releases. See [the documentation on unstable
7 /// features][unstable] for details.
8 ///
9 /// [unstable]: crate#unstable-features
10 #[derive(Debug)]
11 pub(crate) struct SchedulerMetrics {
12     /// Number of tasks that are scheduled from outside the runtime.
13     pub(super) remote_schedule_count: AtomicU64,
14 }
15 
16 impl SchedulerMetrics {
new() -> SchedulerMetrics17     pub(crate) fn new() -> SchedulerMetrics {
18         SchedulerMetrics {
19             remote_schedule_count: AtomicU64::new(0),
20         }
21     }
22 
23     /// Increment the number of tasks scheduled externally
inc_remote_schedule_count(&self)24     pub(crate) fn inc_remote_schedule_count(&self) {
25         self.remote_schedule_count.fetch_add(1, Relaxed);
26     }
27 }
28