diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-12-06 18:34:37 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-12-18 23:31:51 -0800 |
| commit | 43ae4b3301cc0605839778ecf59effb32b752e33 (patch) | |
| tree | aa111f5adc1eaa1e996847e1437d1b1b40821ce0 /src/libstd/sync/rwlock.rs | |
| parent | 14c1a103bc3f78721df1dc860a75a477c8275e3a (diff) | |
| download | rust-43ae4b3301cc0605839778ecf59effb32b752e33.tar.gz rust-43ae4b3301cc0605839778ecf59effb32b752e33.zip | |
Fallout from new thread API
Diffstat (limited to 'src/libstd/sync/rwlock.rs')
| -rw-r--r-- | src/libstd/sync/rwlock.rs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index b6d6aa989c5..1f1e9eea1d6 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -356,7 +356,7 @@ mod tests { use prelude::*; use rand::{mod, Rng}; - use task; + use thread::Thread; use sync::{Arc, RWLock, StaticRWLock, RWLOCK_INIT}; #[test] @@ -409,10 +409,10 @@ mod tests { fn test_rw_arc_poison_wr() { let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); - let _ = task::try(move|| { + let _ = Thread::with_join(move|| { let lock = arc2.write(); assert_eq!(*lock, 2); - }); + }).join(); let lock = arc.read(); assert_eq!(*lock, 1); } @@ -422,10 +422,10 @@ mod tests { fn test_rw_arc_poison_ww() { let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); - let _ = task::try(move|| { + let _ = Thread::with_join(move|| { let lock = arc2.write(); assert_eq!(*lock, 2); - }); + }).join(); let lock = arc.write(); assert_eq!(*lock, 1); } @@ -434,10 +434,10 @@ mod tests { fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); - let _ = task::try(move|| { + let _ = Thread::with_join(move|| { let lock = arc2.read(); assert_eq!(*lock, 2); - }); + }).join(); let lock = arc.read(); assert_eq!(*lock, 1); } @@ -445,10 +445,10 @@ mod tests { fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); - let _ = task::try(move|| { + let _ = Thread::with_join(move|| { let lock = arc2.read(); assert_eq!(*lock, 2); - }); + }).join(); let lock = arc.write(); assert_eq!(*lock, 1); } @@ -459,12 +459,12 @@ mod tests { let arc2 = arc.clone(); let (tx, rx) = channel(); - task::spawn(move|| { + Thread::spawn(move|| { let mut lock = arc2.write(); for _ in range(0u, 10) { let tmp = *lock; *lock = -1; - task::deschedule(); + Thread::yield_now(); *lock = tmp + 1; } tx.send(()); @@ -474,15 +474,15 @@ mod tests { let mut children = Vec::new(); for _ in range(0u, 5) { let arc3 = arc.clone(); - children.push(task::try_future(move|| { + children.push(Thread::with_join(move|| { let lock = arc3.read(); assert!(*lock >= 0); })); } // Wait for children to pass their asserts - for r in children.iter_mut() { - assert!(r.get_ref().is_ok()); + for r in children.into_iter() { + assert!(r.join().is_ok()); } // Wait for writer to finish @@ -495,7 +495,11 @@ mod tests { fn test_rw_arc_access_in_unwind() { let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); +<<<<<<< HEAD let _ = task::try(move|| -> () { +======= + let _ = Thread::with_join::<()>(proc() { +>>>>>>> Fallout from new thread API struct Unwinder { i: Arc<RWLock<int>>, } @@ -507,7 +511,7 @@ mod tests { } let _u = Unwinder { i: arc2 }; panic!(); - }); + }).join(); let lock = arc.read(); assert_eq!(*lock, 2); } |
