Update rustc to 00b112c45a604fa6f4b59af2a40c9deeadfdb7c6/rustc-1.0.0-dev.

This commit is contained in:
Josh Matthews 2015-01-15 13:26:44 -05:00 committed by Glenn Watson
parent ff8cbff810
commit 95fc29fa0d
255 changed files with 3550 additions and 3362 deletions

View file

@ -17,9 +17,11 @@
use task::spawn_named;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::thunk::Thunk;
pub struct TaskPool {
tx: Sender<proc():Send>,
tx: Sender<Thunk<()>>,
}
impl TaskPool {
@ -33,23 +35,25 @@ impl TaskPool {
let state = state.clone();
spawn_named(
format!("TaskPoolWorker {}/{}", i+1, tasks),
proc() worker(&*state));
move || worker(&*state));
}
return TaskPool { tx: tx };
fn worker(rx: &Mutex<Receiver<proc():Send>>) {
fn worker(rx: &Mutex<Receiver<Thunk<()>>>) {
loop {
let job = rx.lock().recv_opt();
let job = rx.lock().unwrap().recv();
match job {
Ok(job) => job(),
Ok(job) => job.invoke(()),
Err(..) => break,
}
}
}
}
pub fn execute(&self, job: proc():Send) {
self.tx.send(job);
pub fn execute<F>(&self, job: F)
where F: FnOnce() + Send
{
self.tx.send(Thunk::new(job));
}
}