about summary refs log tree commit diff
path: root/src/libstd/thread
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/thread
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/thread')
-rw-r--r--src/libstd/thread/mod.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index 1b976b79b4c..1dacf99b64b 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -935,20 +935,17 @@ impl ThreadId {
         static mut COUNTER: u64 = 0;
 
         unsafe {
-            GUARD.lock();
+            let _guard = GUARD.lock();
 
             // If we somehow use up all our bits, panic so that we're not
             // covering up subtle bugs of IDs being reused.
             if COUNTER == ::u64::MAX {
-                GUARD.unlock();
                 panic!("failed to generate unique thread ID: bitspace exhausted");
             }
 
             let id = COUNTER;
             COUNTER += 1;
 
-            GUARD.unlock();
-
             ThreadId(id)
         }
     }