diff options
Diffstat (limited to 'src/libstd/sync/task_pool.rs')
| -rw-r--r-- | src/libstd/sync/task_pool.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index 63c10c18046..c34fa66d12a 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -12,9 +12,9 @@ use core::prelude::*; -use thread::Thread; -use comm::{channel, Sender, Receiver}; use sync::{Arc, Mutex}; +use sync::mpsc::{channel, Sender, Receiver}; +use thread::Thread; use thunk::Thunk; struct Sentinel<'a> { @@ -55,7 +55,7 @@ impl<'a> Drop for Sentinel<'a> { /// ```rust /// use std::sync::TaskPool; /// use std::iter::AdditiveIterator; -/// use std::comm::channel; +/// use std::sync::mpsc::channel; /// /// let pool = TaskPool::new(4u); /// @@ -63,7 +63,7 @@ impl<'a> Drop for Sentinel<'a> { /// for _ in range(0, 8u) { /// let tx = tx.clone(); /// pool.execute(move|| { -/// tx.send(1u); +/// tx.send(1u).unwrap(); /// }); /// } /// @@ -101,7 +101,7 @@ impl TaskPool { pub fn execute<F>(&self, job: F) where F : FnOnce(), F : Send { - self.jobs.send(Thunk::new(job)); + self.jobs.send(Thunk::new(job)).unwrap(); } } @@ -115,7 +115,7 @@ fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) { // Only lock jobs for the time it takes // to get a job, not run it. let lock = jobs.lock().unwrap(); - lock.recv_opt() + lock.recv() }; match message { @@ -134,7 +134,7 @@ fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) { mod test { use prelude::v1::*; use super::*; - use comm::channel; + use sync::mpsc::channel; const TEST_TASKS: uint = 4u; @@ -148,7 +148,7 @@ mod test { for _ in range(0, TEST_TASKS) { let tx = tx.clone(); pool.execute(move|| { - tx.send(1u); + tx.send(1u).unwrap(); }); } @@ -177,7 +177,7 @@ mod test { for _ in range(0, TEST_TASKS) { let tx = tx.clone(); pool.execute(move|| { - tx.send(1u); + tx.send(1u).unwrap(); }); } |
