mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
no reason to use mutable references here at all
This commit is contained in:
@@ -172,27 +172,19 @@ pub unsafe fn init(&mut self) {
|
||||
}
|
||||
|
||||
pub unsafe fn lock(&self) {
|
||||
// `init` must have been called, so this is now initialized and
|
||||
// we can call `get_mut`.
|
||||
c::EnterCriticalSection((&mut *self.inner.get()).get_mut());
|
||||
c::EnterCriticalSection((&mut *self.inner.get()).as_mut_ptr());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn try_lock(&self) -> bool {
|
||||
// `init` must have been called, so this is now initialized and
|
||||
// we can call `get_mut`.
|
||||
c::TryEnterCriticalSection((&mut *self.inner.get()).get_mut()) != 0
|
||||
c::TryEnterCriticalSection((&mut *self.inner.get()).as_mut_ptr()) != 0
|
||||
}
|
||||
|
||||
pub unsafe fn unlock(&self) {
|
||||
// `init` must have been called, so this is now initialized and
|
||||
// we can call `get_mut`.
|
||||
c::LeaveCriticalSection((&mut *self.inner.get()).get_mut());
|
||||
c::LeaveCriticalSection((&mut *self.inner.get()).as_mut_ptr());
|
||||
}
|
||||
|
||||
pub unsafe fn destroy(&self) {
|
||||
// `init` must have been called, so this is now initialized and
|
||||
// we can call `get_mut`.
|
||||
c::DeleteCriticalSection((&mut *self.inner.get()).get_mut());
|
||||
c::DeleteCriticalSection((&mut *self.inner.get()).as_mut_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user