#[inline] pubfn lock(&self) -> Pin<CMutexGuard<'_, T>> { letmut sguard = self.spin_lock.acquire(); ifself.locked.get() {
stack_pin_init!(let wait_entry = WaitEntry::insert_new(&self.wait_list)); // println!("wait list length: {}", self.wait_list.size()); whileself.locked.get() {
drop(sguard); #[cfg(feature = "std")]
thread::park();
sguard = self.spin_lock.acquire();
} // This does have an effect, as the ListHead inside wait_entry implements Drop! #[expect(clippy::drop_non_drop)]
drop(wait_entry);
} self.locked.set(true); unsafe {
Pin::new_unchecked(CMutexGuard {
mtx: self,
_pin: PhantomPinned,
})
}
}
#[allow(dead_code)] pubfn get_data_mut(self: Pin<&mutSelf>) -> &>mut T { // SAFETY: we have an exclusive reference and thus nobody has access to data. unsafe { &mut *self.data.get() }
}
}
unsafeimpl<T: Send> Send for CMutex<T> {} unsafeimpl<T: Send> Sync for CMutex<T> {}
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.