#[cold] fn register<C: cfg::Config>(&self) -> Tid<C> { let id = REGISTRY
.free
.lock()
.ok()
.and_then(|mut free| { if free.len() > 1 {
free.pop_front()
} else {
None
}
})
.unwrap_or_else(|| { let id = REGISTRY.next.fetch_add(1, Ordering::AcqRel); if id > Tid::<C>::BITS {
panic_in_drop!( "creating a new thread ID ({}) would exceed the \
maximum number of thread ID bits specified in {} \
({})",
id,
std::any::type_name::<C>(),
Tid::<C>::BITS,
);
}
id
});
self.0.set(Some(id));
Tid::new(id)
}
}
// Reusing thread IDs doesn't work under loom, since this `Drop` impl results in // an access to a `loom` lazy_static while the test is shutting down, which // panics. T_T // Just skip TID reuse and use loom's lazy_static macro to ensure we have a // clean initial TID on every iteration, instead. #[cfg(not(all(loom, any(feature = "loom", test))))] impl Drop for Registration { fn drop(&mutself) { use std::sync::PoisonError;
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.