diff options
| author | bors <bors@rust-lang.org> | 2018-06-17 20:11:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-17 20:11:35 +0000 |
| commit | 86a8f1a6374dd558ebdafe061e61720a73ae732c (patch) | |
| tree | b2e2ad7987a2ffd9c8b987c38710b68206452c2f /src/libstd/sync | |
| parent | 2b973e653257f965e33a61b58c0eb7e863aed6c8 (diff) | |
| parent | b81da278623d9dcda1776008612bd42e1922e9c3 (diff) | |
| download | rust-86a8f1a6374dd558ebdafe061e61720a73ae732c.tar.gz rust-86a8f1a6374dd558ebdafe061e61720a73ae732c.zip | |
Auto merge of #51529 - nodakai:improve-sys_common-mutex, r=oli-obk
libstd: add an RAII utility for sys_common::mutex::Mutex It is indeed debatable whether or not we should introduce more sophistication like this to the lowest layer of a system library. In fact, `Drop::drop()` cannot be `unsafe` (IIRC there was a discussion on introducing an unsafe variant of `Drop` whose entire scope must be within `unsafe`)
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index f3503b0b3a6..e5a410644b9 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -227,7 +227,7 @@ impl<T: ?Sized> Mutex<T> { #[stable(feature = "rust1", since = "1.0.0")] pub fn lock(&self) -> LockResult<MutexGuard<T>> { unsafe { - self.inner.lock(); + self.inner.raw_lock(); MutexGuard::new(self) } } @@ -454,7 +454,7 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { fn drop(&mut self) { unsafe { self.__lock.poison.done(&self.__poison); - self.__lock.inner.unlock(); + self.__lock.inner.raw_unlock(); } } } |
