1
Fork 0

std: replace pthread RwLock with custom implementation inspired by usync

This commit is contained in:
joboet 2023-04-12 00:04:58 +02:00
parent 972452c447
commit 934eb8b391
No known key found for this signature in database
GPG key ID: 704E0149B0194B3C
5 changed files with 506 additions and 198 deletions

View file

@ -1063,7 +1063,7 @@ pub fn park() {
let guard = PanicGuard;
// SAFETY: park_timeout is called on the parker owned by this thread.
unsafe {
current().inner.as_ref().parker().park();
current().park();
}
// No panic occurred, do not abort.
forget(guard);
@ -1290,6 +1290,15 @@ impl Thread {
Thread { inner }
}
/// Like the public [`park`], but callable on any handle. Used to allow
/// parking in TLS destructors.
///
/// # Safety
/// May only be called from the thread to which this handle belongs.
pub(crate) unsafe fn park(&self) {
unsafe { self.inner.as_ref().parker().park() }
}
/// Atomically makes the handle's token available if it is not already.
///
/// Every thread is equipped with some basic low-level blocking support, via