no reason to use mutable references here at all
This commit is contained in:
parent
dd593d3ab8
commit
f9fb8d6435
1 changed files with 4 additions and 12 deletions
|
@ -172,27 +172,19 @@ impl ReentrantMutex {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn lock(&self) {
|
pub unsafe fn lock(&self) {
|
||||||
// `init` must have been called, so this is now initialized and
|
c::EnterCriticalSection((&mut *self.inner.get()).as_mut_ptr());
|
||||||
// we can call `get_mut`.
|
|
||||||
c::EnterCriticalSection((&mut *self.inner.get()).get_mut());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn try_lock(&self) -> bool {
|
pub unsafe fn try_lock(&self) -> bool {
|
||||||
// `init` must have been called, so this is now initialized and
|
c::TryEnterCriticalSection((&mut *self.inner.get()).as_mut_ptr()) != 0
|
||||||
// we can call `get_mut`.
|
|
||||||
c::TryEnterCriticalSection((&mut *self.inner.get()).get_mut()) != 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn unlock(&self) {
|
pub unsafe fn unlock(&self) {
|
||||||
// `init` must have been called, so this is now initialized and
|
c::LeaveCriticalSection((&mut *self.inner.get()).as_mut_ptr());
|
||||||
// we can call `get_mut`.
|
|
||||||
c::LeaveCriticalSection((&mut *self.inner.get()).get_mut());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy(&self) {
|
pub unsafe fn destroy(&self) {
|
||||||
// `init` must have been called, so this is now initialized and
|
c::DeleteCriticalSection((&mut *self.inner.get()).as_mut_ptr());
|
||||||
// we can call `get_mut`.
|
|
||||||
c::DeleteCriticalSection((&mut *self.inner.get()).get_mut());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue