diff options
Diffstat (limited to 'src/libstd/sync/mutex.rs')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 98425f26c1a..3f155b02065 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -48,7 +48,7 @@ use sys_common::mutex as sys; /// ```rust /// use std::sync::{Arc, Mutex}; /// use std::thread::Thread; -/// use std::comm::channel; +/// use std::sync::mpsc::channel; /// /// const N: uint = 10; /// @@ -72,13 +72,13 @@ use sys_common::mutex as sys; /// let mut data = data.lock().unwrap(); /// *data += 1; /// if *data == N { -/// tx.send(()); +/// tx.send(()).unwrap(); /// } /// // the lock is unlocked here when `data` goes out of scope. /// }).detach(); /// } /// -/// rx.recv(); +/// rx.recv().unwrap(); /// ``` /// /// To recover from a poisoned mutex: @@ -325,7 +325,7 @@ pub fn guard_poison<'a, T>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag { mod test { use prelude::v1::*; - use comm::channel; + use sync::mpsc::channel; use sync::{Arc, Mutex, StaticMutex, MUTEX_INIT, Condvar}; use thread::Thread; @@ -370,14 +370,14 @@ mod test { let (tx, rx) = channel(); for _ in range(0, K) { let tx2 = tx.clone(); - Thread::spawn(move|| { inc(); tx2.send(()); }).detach(); + Thread::spawn(move|| { inc(); tx2.send(()).unwrap(); }).detach(); let tx2 = tx.clone(); - Thread::spawn(move|| { inc(); tx2.send(()); }).detach(); + Thread::spawn(move|| { inc(); tx2.send(()).unwrap(); }).detach(); } drop(tx); for _ in range(0, 2 * K) { - rx.recv(); + rx.recv().unwrap(); } assert_eq!(unsafe {CNT}, J * K * 2); unsafe { @@ -398,7 +398,7 @@ mod test { let (tx, rx) = channel(); let _t = Thread::spawn(move|| { // wait until parent gets in - rx.recv(); + rx.recv().unwrap(); let &(ref lock, ref cvar) = &*packet2.0; let mut lock = lock.lock().unwrap(); *lock = true; @@ -407,7 +407,7 @@ mod test { let &(ref lock, ref cvar) = &*packet.0; let mut lock = lock.lock().unwrap(); - tx.send(()); + tx.send(()).unwrap(); assert!(!*lock); while !*lock { lock = cvar.wait(lock).unwrap(); @@ -421,7 +421,7 @@ mod test { let (tx, rx) = channel(); let _t = Thread::spawn(move || -> () { - rx.recv(); + rx.recv().unwrap(); let &(ref lock, ref cvar) = &*packet2.0; let _g = lock.lock().unwrap(); cvar.notify_one(); @@ -431,7 +431,7 @@ mod test { let &(ref lock, ref cvar) = &*packet.0; let mut lock = lock.lock().unwrap(); - tx.send(()); + tx.send(()).unwrap(); while *lock == 1 { match cvar.wait(lock) { Ok(l) => { @@ -465,9 +465,9 @@ mod test { let lock = arc2.lock().unwrap(); let lock2 = lock.lock().unwrap(); assert_eq!(*lock2, 1); - tx.send(()); + tx.send(()).unwrap(); }); - rx.recv(); + rx.recv().unwrap(); } #[test] |
