about summary refs log tree commit diff
path: root/src/libstd/sys/common/mutex.rs
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2015-05-27 11:18:36 +0300
committerEduard Burtescu <edy.burt@gmail.com>2015-05-27 11:19:03 +0300
commit377b0900aede976b2d37a499bbd7b62c2e39b358 (patch)
treeb4a5a4431d36ed1a4e0a39c7d2ef2563ecac9bf4 /src/libstd/sys/common/mutex.rs
parent6e8e4f847c2ea02fec021ea15dfb2de6beac797a (diff)
downloadrust-377b0900aede976b2d37a499bbd7b62c2e39b358.tar.gz
rust-377b0900aede976b2d37a499bbd7b62c2e39b358.zip
Use `const fn` to abstract away the contents of UnsafeCell & friends.
Diffstat (limited to 'src/libstd/sys/common/mutex.rs')
-rw-r--r--src/libstd/sys/common/mutex.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstd/sys/common/mutex.rs b/src/libstd/sys/common/mutex.rs
index 1f9dd54192c..5a6dfe7fb1a 100644
--- a/src/libstd/sys/common/mutex.rs
+++ b/src/libstd/sys/common/mutex.rs
@@ -20,10 +20,13 @@ pub struct Mutex(imp::Mutex);
 
 unsafe impl Sync for Mutex {}
 
-/// Constant initializer for statically allocated mutexes.
-pub const MUTEX_INIT: Mutex = Mutex(imp::MUTEX_INIT);
-
 impl Mutex {
+    /// Creates a new mutex for use.
+    ///
+    /// Behavior is undefined if the mutex is moved after it is
+    /// first used with any of the functions below.
+    pub const fn new() -> Mutex { Mutex(imp::Mutex::new()) }
+
     /// Locks the mutex blocking the current thread until it is available.
     ///
     /// Behavior is undefined if the mutex has been moved between this and any