about summary refs log tree commit diff
path: root/src/libsync
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-10 21:59:10 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-10 22:09:49 -0700
commitdae48a07f34dcf714b3b57029f4e03a0b95a269e (patch)
tree4ced3fe4c6c167508f0f7d1308473dfec676846d /src/libsync
parent1add4dedc131d5f98d82feafe80d92ed1f3f6d49 (diff)
downloadrust-dae48a07f34dcf714b3b57029f4e03a0b95a269e.tar.gz
rust-dae48a07f34dcf714b3b57029f4e03a0b95a269e.zip
Register new snapshots
Also convert a number of `static mut` to just a plain old `static` and remove
some unsafe blocks.
Diffstat (limited to 'src/libsync')
-rw-r--r--src/libsync/atomic.rs8
-rw-r--r--src/libsync/deque.rs6
-rw-r--r--src/libsync/mutex.rs8
-rw-r--r--src/libsync/one.rs18
4 files changed, 18 insertions, 22 deletions
diff --git a/src/libsync/atomic.rs b/src/libsync/atomic.rs
index cd7102a756a..e853e44d6f9 100644
--- a/src/libsync/atomic.rs
+++ b/src/libsync/atomic.rs
@@ -93,12 +93,10 @@
 //! ```
 //! use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
 //!
-//! static mut GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
+//! static GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
 //!
-//! unsafe {
-//!     let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst);
-//!     println!("live tasks: {}", old_task_count + 1);
-//! }
+//! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst);
+//! println!("live tasks: {}", old_task_count + 1);
 //! ```
 
 #![allow(deprecated)]
diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs
index 15c0c14b28a..33881629329 100644
--- a/src/libsync/deque.rs
+++ b/src/libsync/deque.rs
@@ -545,8 +545,8 @@ mod tests {
     fn stress() {
         static AMT: int = 100000;
         static NTHREADS: int = 8;
-        static mut DONE: AtomicBool = INIT_ATOMIC_BOOL;
-        static mut HITS: AtomicUint = INIT_ATOMIC_UINT;
+        static DONE: AtomicBool = INIT_ATOMIC_BOOL;
+        static HITS: AtomicUint = INIT_ATOMIC_UINT;
         let pool = BufferPool::<int>::new();
         let (w, s) = pool.deque();
 
@@ -604,7 +604,7 @@ mod tests {
     fn no_starvation() {
         static AMT: int = 10000;
         static NTHREADS: int = 4;
-        static mut DONE: AtomicBool = INIT_ATOMIC_BOOL;
+        static DONE: AtomicBool = INIT_ATOMIC_BOOL;
         let pool = BufferPool::<(int, uint)>::new();
         let (w, s) = pool.deque();
 
diff --git a/src/libsync/mutex.rs b/src/libsync/mutex.rs
index c6413d0d09c..9861d27c8cd 100644
--- a/src/libsync/mutex.rs
+++ b/src/libsync/mutex.rs
@@ -127,9 +127,9 @@ enum Flavor {
 /// ```rust
 /// use sync::mutex::{StaticMutex, MUTEX_INIT};
 ///
-/// static mut LOCK: StaticMutex = MUTEX_INIT;
+/// static LOCK: StaticMutex = MUTEX_INIT;
 ///
-/// unsafe {
+/// {
 ///     let _g = LOCK.lock();
 ///     // do some productive work
 /// }
@@ -536,7 +536,7 @@ mod test {
 
     #[test]
     fn smoke_static() {
-        static mut m: StaticMutex = MUTEX_INIT;
+        static m: StaticMutex = MUTEX_INIT;
         unsafe {
             drop(m.lock());
             drop(m.lock());
@@ -546,7 +546,7 @@ mod test {
 
     #[test]
     fn lots_and_lots() {
-        static mut m: StaticMutex = MUTEX_INIT;
+        static m: StaticMutex = MUTEX_INIT;
         static mut CNT: uint = 0;
         static M: uint = 1000;
         static N: uint = 3;
diff --git a/src/libsync/one.rs b/src/libsync/one.rs
index c740c4f3d2e..f0c72780be1 100644
--- a/src/libsync/one.rs
+++ b/src/libsync/one.rs
@@ -30,13 +30,11 @@ use mutex::{StaticMutex, MUTEX_INIT};
 /// ```rust
 /// use sync::one::{Once, ONCE_INIT};
 ///
-/// static mut START: Once = ONCE_INIT;
+/// static START: Once = ONCE_INIT;
 ///
-/// unsafe {
-///     START.doit(|| {
-///         // run initialization here
-///     });
-/// }
+/// START.doit(|| {
+///     // run initialization here
+/// });
 /// ```
 pub struct Once {
     mutex: StaticMutex,
@@ -128,17 +126,17 @@ mod test {
 
     #[test]
     fn smoke_once() {
-        static mut o: Once = ONCE_INIT;
+        static o: Once = ONCE_INIT;
         let mut a = 0i;
-        unsafe { o.doit(|| a += 1); }
+        o.doit(|| a += 1);
         assert_eq!(a, 1);
-        unsafe { o.doit(|| a += 1); }
+        o.doit(|| a += 1);
         assert_eq!(a, 1);
     }
 
     #[test]
     fn stampede_once() {
-        static mut o: Once = ONCE_INIT;
+        static o: Once = ONCE_INIT;
         static mut run: bool = false;
 
         let (tx, rx) = channel();