Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  thread.rs

  Sprache: Rust
 

use std::io;
use std::thread::{self, JoinHandle};

#[cfg(all(feature = "gecko", not(target_os = "android")))]
mod bindings {
    extern "C" {
        pub fn gecko_profiler_register_thread(name: *const std::ffi::c_char);
        pub fn gecko_profiler_unregister_thread();
    }
}

/// Register a thread with the Gecko Profiler.
#[cfg(all(feature = "gecko", not(target_os = "android")))]
fn register_thread(thread_name: &str) {
    let name = std::ffi::CString::new(thread_name).unwrap();
    unsafe {
        // gecko_profiler_register_thread copies the passed name here.
        bindings::gecko_profiler_register_thread(name.as_ptr());
    }
}

#[cfg(any(not(feature = "gecko"), target_os = "android"))]
fn register_thread(_thread_name: &str) {}

/// Unregister a thread with the Gecko Profiler.
#[cfg(all(feature = "gecko", not(target_os = "android")))]
fn unregister_thread() {
    unsafe {
        bindings::gecko_profiler_unregister_thread();
    }
}
#[cfg(any(not(feature = "gecko"), target_os = "android"))]
fn unregister_thread() {}

/// Spawns a new thread, returning a [`JoinHandle`] for it.
///
/// Wrapper around [`std::thread::spawn`], but automatically naming the thread.
pub fn spawn<F, T>(name: &'static str, f: F) -> Result<JoinHandle<T>, io::Error>
where
    F: FnOnce() -> T + Send + 'static,
    T: Send + 'static,
{
    thread::Builder::new()
        .name(name.to_string())
        .spawn(move || {
            register_thread(name);
            let res = f();
            unregister_thread();
            res
        })
}

Messung V0.5 in Prozent
C=89 H=82 G=85

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-08-27) ¤

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=434850
#Domains=661743