about summary refs log tree commit diff
path: root/src/libstd/sys/common/remutex.rs
diff options
context:
space:
mode:
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
         }
     }