about summary refs log tree commit diff
path: root/src/libstd/sys/common/remutex.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-08 01:32:59 +0000
committerbors <bors@rust-lang.org>2015-05-08 01:32:59 +0000
commitcf76e637450a861e94ef583340b8f080379a159a (patch)
treef01e7c305dbe832c5283d229168223c5e8a24cf7 /src/libstd/sys/common/remutex.rs
parentb402c43f088882db8a03bfcbb5eb8429ef7def0e (diff)
parent7529bd60c3cbc4c7b635ee43a89d5b14f6fb8bf7 (diff)
downloadrust-cf76e637450a861e94ef583340b8f080379a159a.tar.gz
rust-cf76e637450a861e94ef583340b8f080379a159a.zip
Auto merge of #25136 - alexcrichton:drop-the-two, r=aturon
* Remove the 2-suffix from some modules
* Remove some unused files
* Remove double-boxing for `ReentrantMutex`
Diffstat (limited to 'src/libstd/sys/common/remutex.rs')
-rw-r--r--src/libstd/sys/common/remutex.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs
index 48c74b8d89e..1a467580672 100644
--- a/src/libstd/sys/common/remutex.rs
+++ b/src/libstd/sys/common/remutex.rs
@@ -19,9 +19,9 @@ use sys::mutex as sys;
 
 /// A re-entrant mutual exclusion
 ///
-/// This mutex will block *other* threads waiting for the lock to become available. The thread
-/// which has already locked the mutex can lock it multiple times without blocking, preventing a
-/// common source of deadlocks.
+/// This mutex will block *other* threads waiting for the lock to become
+/// available. The thread which has already locked the mutex can lock it
+/// multiple times without blocking, preventing a common source of deadlocks.
 pub struct ReentrantMutex<T> {
     inner: Box<sys::ReentrantMutex>,
     poison: poison::Flag,
@@ -51,10 +51,14 @@ impl<'a, T> !marker::Send for ReentrantMutexGuard<'a, T> {}
 impl<T> ReentrantMutex<T> {
     /// Creates a new reentrant mutex in an unlocked state.
     pub fn new(t: T) -> ReentrantMutex<T> {
-        ReentrantMutex {
-            inner: box unsafe { sys::ReentrantMutex::new() },
-            poison: poison::FLAG_INIT,
-            data: t,
+        unsafe {
+            let mut mutex = ReentrantMutex {
+                inner: box sys::ReentrantMutex::uninitialized(),
+                poison: poison::FLAG_INIT,
+                data: t,
+            };
+            mutex.inner.init();
+            return mutex
         }
     }