about summary refs log tree commit diff
path: root/src/libstd/sys_common/thread_local.rs
diff options
context:
space:
mode:
authorNODA, Kai <nodakai@gmail.com>2018-06-09 21:13:04 +0800
committerNODA, Kai <nodakai@gmail.com>2018-06-17 15:18:32 +0800
commitb81da278623d9dcda1776008612bd42e1922e9c3 (patch)
tree9aea5b4aef36eeffec197b0afb61c160e1b8c2be /src/libstd/sys_common/thread_local.rs
parent0f8f4903f73a21d7f408870551c08acd051abeb0 (diff)
downloadrust-b81da278623d9dcda1776008612bd42e1922e9c3.tar.gz
rust-b81da278623d9dcda1776008612bd42e1922e9c3.zip
libstd: add an RAII utility for sys_common::mutex::Mutex
Signed-off-by: NODA, Kai <nodakai@gmail.com>
Diffstat (limited to 'src/libstd/sys_common/thread_local.rs')
-rw-r--r--src/libstd/sys_common/thread_local.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libstd/sys_common/thread_local.rs b/src/libstd/sys_common/thread_local.rs
index d0d6224de0a..75f6b9ac7fd 100644
--- a/src/libstd/sys_common/thread_local.rs
+++ b/src/libstd/sys_common/thread_local.rs
@@ -162,13 +162,12 @@ impl StaticKey {
         // we just simplify the whole branch.
         if imp::requires_synchronized_create() {
             static INIT_LOCK: Mutex = Mutex::new();
-            INIT_LOCK.lock();
+            let _guard = INIT_LOCK.lock();
             let mut key = self.key.load(Ordering::SeqCst);
             if key == 0 {
                 key = imp::create(self.dtor) as usize;
                 self.key.store(key, Ordering::SeqCst);
             }
-            INIT_LOCK.unlock();
             rtassert!(key != 0);
             return key
         }