Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/tokio/src/runtime/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1015 B image not shown  

Quelle  thread_id.rs

  Sprache: Rust
 

use std::num::NonZeroU64;

#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
pub(cratestruct ThreadId(NonZeroU64);

impl ThreadId {
    pub(cratefn next() -> Self {
        use crate::loom::sync::atomic::{AtomicU64, Ordering::Relaxed};

        #[cfg(all(test, loom))]
        crate::loom::lazy_static! {
            static ref NEXT_ID: AtomicU64 = AtomicU64::new(0);
        }

        #[cfg(not(all(test, loom)))]
        static NEXT_ID: AtomicU64 = AtomicU64::new(0);

        let mut last = NEXT_ID.load(Relaxed);
        loop {
            let id = match last.checked_add(1) {
                Some(id) => id,
                None => exhausted(),
            };

            match NEXT_ID.compare_exchange_weak(last, id, Relaxed, Relaxed) {
                Ok(_) => return ThreadId(NonZeroU64::new(id).unwrap()),
                Err(id) => last = id,
            }
        }
    }
}

#[cold]
#[allow(dead_code)]
fn exhausted() -> ! {
    panic!("failed to generate unique thread ID: bitspace exhausted")
}

Messung V0.5 in Prozent
C=91 H=99 G=94

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.