Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/tokio/src/util/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  metric_atomics.rs

  Sprache: Rust
 

use std::sync::atomic::{AtomicUsize, Ordering};

cfg_64bit_metrics! {
    use std::sync::atomic::AtomicU64;
}

/// `AtomicU64` that is is a no-op on platforms without 64-bit atomics
///
/// When used on platforms without 64-bit atomics, writes to this are no-ops.
/// The `load` method is only defined when 64-bit atomics are available.
#[derive(Debug, Default)]
pub(cratestruct MetricAtomicU64 {
    #[cfg(target_has_atomic = "64")]
    value: AtomicU64,
}

// some of these are currently only used behind cfg_unstable
#[allow(dead_code)]
impl MetricAtomicU64 {
    // Load is only defined when supported
    cfg_64bit_metrics! {
        pub(cratefn load(&self, ordering: Ordering) -> u64 {
            self.value.load(ordering)
        }
    }

    cfg_64bit_metrics! {
        pub(cratefn store(&self, val: u64, ordering: Ordering) {
            self.value.store(val, ordering)
        }

        pub(cratefn new(value: u64) -> Self {
            Self { value: AtomicU64::new(value) }
        }

        pub(cratefn add(&self, value: u64, ordering: Ordering) {
            self.value.fetch_add(value, ordering);
        }
    }

    cfg_no_64bit_metrics! {
        pub(cratefn store(&self, _val: u64, _ordering: Ordering) { }
        // on platforms without 64-bit atomics, fetch-add returns unit
        pub(cratefn add(&self, _value: u64, _ordering: Ordering) {  }
        pub(cratefn new(_value: u64) -> Self { Self { } }
    }
}

#[cfg_attr(not(all(tokio_unstable, feature = "rt")), allow(dead_code))]
/// `AtomicUsize` for use in metrics.
///
/// This exposes simplified APIs for use in metrics & uses `std::sync` instead of Loom to avoid polluting loom logs with metric information.
#[derive(Debug, Default)]
pub(cratestruct MetricAtomicUsize {
    value: AtomicUsize,
}

#[cfg_attr(not(all(tokio_unstable, feature = "rt")), allow(dead_code))]
impl MetricAtomicUsize {
    pub(cratefn new(value: usize) -> Self {
        Self {
            value: AtomicUsize::new(value),
        }
    }

    pub(cratefn load(&self, ordering: Ordering) -> usize {
        self.value.load(ordering)
    }

    pub(cratefn store(&self, val: usize, ordering: Ordering) {
        self.value.store(val, ordering)
    }

    pub(cratefn increment(&self) -> usize {
        self.value.fetch_add(1, Ordering::Relaxed)
    }

    pub(cratefn decrement(&self) -> usize {
        self.value.fetch_sub(1, Ordering::Relaxed)
    }
}

Messung V0.5 in Prozent
C=88 H=100 G=94

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-06-21) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.