about summary refs log tree commit diff
path: root/src/libsync
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-14 04:02:48 +0000
committerbors <bors@rust-lang.org>2014-10-14 04:02:48 +0000
commita1e2eb0395941f5ca79cd59c8ab0a9f3133a2df0 (patch)
tree2782a6efa84382e234077244930b2d78d54ce7ee /src/libsync
parent1c3ddd297128a96f72be09bddf138e4e603a7aa1 (diff)
parent2e2d681d88d99c4bb7033b852f98d6f979af5672 (diff)
downloadrust-a1e2eb0395941f5ca79cd59c8ab0a9f3133a2df0.tar.gz
rust-a1e2eb0395941f5ca79cd59c8ab0a9f3133a2df0.zip
auto merge of #18017 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libsync')
-rw-r--r--src/libsync/comm/duplex.rs3
-rw-r--r--src/libsync/deque.rs34
-rw-r--r--src/libsync/mutex.rs26
-rw-r--r--src/libsync/one.rs12
4 files changed, 36 insertions, 39 deletions
diff --git a/src/libsync/comm/duplex.rs b/src/libsync/comm/duplex.rs
index 587827d2bc5..1dc1f4b87f2 100644
--- a/src/libsync/comm/duplex.rs
+++ b/src/libsync/comm/duplex.rs
@@ -59,10 +59,11 @@ impl<S:Send,R:Send> DuplexStream<S, R> {
     }
 }
 
+#[allow(deprecated)]
 #[cfg(test)]
 mod test {
     use std::prelude::*;
-    use comm::{duplex};
+    use comm::duplex;
 
     #[test]
     pub fn duplex_stream_1() {
diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs
index 33881629329..09fa8920a07 100644
--- a/src/libsync/deque.rs
+++ b/src/libsync/deque.rs
@@ -553,14 +553,12 @@ mod tests {
         let threads = range(0, NTHREADS).map(|_| {
             let s = s.clone();
             Thread::start(proc() {
-                unsafe {
-                    loop {
-                        match s.steal() {
-                            Data(2) => { HITS.fetch_add(1, SeqCst); }
-                            Data(..) => fail!(),
-                            _ if DONE.load(SeqCst) => break,
-                            _ => {}
-                        }
+                loop {
+                    match s.steal() {
+                        Data(2) => { HITS.fetch_add(1, SeqCst); }
+                        Data(..) => fail!(),
+                        _ if DONE.load(SeqCst) => break,
+                        _ => {}
                     }
                 }
             })
@@ -572,7 +570,7 @@ mod tests {
             if rng.gen_range(0i, 3) == 2 {
                 match w.pop() {
                     None => {}
-                    Some(2) => unsafe { HITS.fetch_add(1, SeqCst); },
+                    Some(2) => { HITS.fetch_add(1, SeqCst); },
                     Some(_) => fail!(),
                 }
             } else {
@@ -581,22 +579,20 @@ mod tests {
             }
         }
 
-        unsafe {
-            while HITS.load(SeqCst) < AMT as uint {
-                match w.pop() {
-                    None => {}
-                    Some(2) => { HITS.fetch_add(1, SeqCst); },
-                    Some(_) => fail!(),
-                }
+        while HITS.load(SeqCst) < AMT as uint {
+            match w.pop() {
+                None => {}
+                Some(2) => { HITS.fetch_add(1, SeqCst); },
+                Some(_) => fail!(),
             }
-            DONE.store(true, SeqCst);
         }
+        DONE.store(true, SeqCst);
 
         for thread in threads.into_iter() {
             thread.join();
         }
 
-        assert_eq!(unsafe { HITS.load(SeqCst) }, expected as uint);
+        assert_eq!(HITS.load(SeqCst), expected as uint);
     }
 
     #[test]
@@ -655,7 +651,7 @@ mod tests {
             }
         }
 
-        unsafe { DONE.store(true, SeqCst); }
+        DONE.store(true, SeqCst);
 
         for thread in threads.into_iter() {
             thread.join();
diff --git a/src/libsync/mutex.rs b/src/libsync/mutex.rs
index 9861d27c8cd..796c62354c3 100644
--- a/src/libsync/mutex.rs
+++ b/src/libsync/mutex.rs
@@ -536,32 +536,32 @@ mod test {
 
     #[test]
     fn smoke_static() {
-        static m: StaticMutex = MUTEX_INIT;
+        static M: StaticMutex = MUTEX_INIT;
         unsafe {
-            drop(m.lock());
-            drop(m.lock());
-            m.destroy();
+            drop(M.lock());
+            drop(M.lock());
+            M.destroy();
         }
     }
 
     #[test]
     fn lots_and_lots() {
-        static m: StaticMutex = MUTEX_INIT;
+        static M: StaticMutex = MUTEX_INIT;
         static mut CNT: uint = 0;
-        static M: uint = 1000;
-        static N: uint = 3;
+        static J: uint = 1000;
+        static K: uint = 3;
 
         fn inc() {
-            for _ in range(0, M) {
+            for _ in range(0, J) {
                 unsafe {
-                    let _g = m.lock();
+                    let _g = M.lock();
                     CNT += 1;
                 }
             }
         }
 
         let (tx, rx) = channel();
-        for _ in range(0, N) {
+        for _ in range(0, K) {
             let tx2 = tx.clone();
             native::task::spawn(proc() { inc(); tx2.send(()); });
             let tx2 = tx.clone();
@@ -569,12 +569,12 @@ mod test {
         }
 
         drop(tx);
-        for _ in range(0, 2 * N) {
+        for _ in range(0, 2 * K) {
             rx.recv();
         }
-        assert_eq!(unsafe {CNT}, M * N * 2);
+        assert_eq!(unsafe {CNT}, J * K * 2);
         unsafe {
-            m.destroy();
+            M.destroy();
         }
     }
 
diff --git a/src/libsync/one.rs b/src/libsync/one.rs
index f0c72780be1..62b37660912 100644
--- a/src/libsync/one.rs
+++ b/src/libsync/one.rs
@@ -126,17 +126,17 @@ mod test {
 
     #[test]
     fn smoke_once() {
-        static o: Once = ONCE_INIT;
+        static O: Once = ONCE_INIT;
         let mut a = 0i;
-        o.doit(|| a += 1);
+        O.doit(|| a += 1);
         assert_eq!(a, 1);
-        o.doit(|| a += 1);
+        O.doit(|| a += 1);
         assert_eq!(a, 1);
     }
 
     #[test]
     fn stampede_once() {
-        static o: Once = ONCE_INIT;
+        static O: Once = ONCE_INIT;
         static mut run: bool = false;
 
         let (tx, rx) = channel();
@@ -145,7 +145,7 @@ mod test {
             spawn(proc() {
                 for _ in range(0u, 4) { task::deschedule() }
                 unsafe {
-                    o.doit(|| {
+                    O.doit(|| {
                         assert!(!run);
                         run = true;
                     });
@@ -156,7 +156,7 @@ mod test {
         }
 
         unsafe {
-            o.doit(|| {
+            O.doit(|| {
                 assert!(!run);
                 run = true;
             });