Closed dynos01 closed 1 year ago
For point 2, this does compile, but will it work as expected? (I don't have experience with crate critical-section
, and the definitions of borrow
and borrow_mut
here look different)
pub(crate) unsafe fn get_mut_unchecked(&mut self) -> &mut T {
debug_assert!(self.is_initialized());
// SAFETY: The caller ensures that the value is initialized and access synchronized.
crate::unwrap_unchecked(self.value.borrow_mut().get_mut().get_mut())
}
I added
get_mut_unchecked()
as it might help someone.Also, there are two things I'm considering but currently unsure about how to correctly implement:
wait_mut()
. However mutable reference across threads requires Mutex, but waiting with Mutex acquired will block other threads from initializing the value. Is there a case that this will make sense?get_mut_unchecked()
inimp_cs.rs
. This seems to require modification of the upstream cratecritical_section
, so I skipped it for now.