Sha256: d384da20159a9f60c87d892be92c6e95c065791d8062ac72fda2a0c053786c58

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

use crate::loom::sync::atomic::Ordering::Relaxed;
use crate::util::metric_atomics::MetricAtomicU64;

/// Retrieves metrics from the Tokio runtime.
///
/// **Note**: This is an [unstable API][unstable]. The public API of this type
/// may break in 1.x releases. See [the documentation on unstable
/// features][unstable] for details.
///
/// [unstable]: crate#unstable-features
#[derive(Debug)]
pub(crate) struct SchedulerMetrics {
    /// Number of tasks that are scheduled from outside the runtime.
    pub(super) remote_schedule_count: MetricAtomicU64,
    pub(super) budget_forced_yield_count: MetricAtomicU64,
}

impl SchedulerMetrics {
    pub(crate) fn new() -> SchedulerMetrics {
        SchedulerMetrics {
            remote_schedule_count: MetricAtomicU64::new(0),
            budget_forced_yield_count: MetricAtomicU64::new(0),
        }
    }

    /// Increment the number of tasks scheduled externally
    pub(crate) fn inc_remote_schedule_count(&self) {
        self.remote_schedule_count.add(1, Relaxed);
    }

    /// Increment the number of tasks forced to yield due to budget exhaustion
    pub(crate) fn inc_budget_forced_yield_count(&self) {
        self.budget_forced_yield_count.add(1, Relaxed);
    }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/metrics/scheduler.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/metrics/scheduler.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/src/runtime/metrics/scheduler.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/src/runtime/metrics/scheduler.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/src/runtime/metrics/scheduler.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/metrics/scheduler.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/metrics/scheduler.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/metrics/scheduler.rs