Run all task spawning through util, to allow for easy hooking.

During debugging, I found it useful to hook all task creation in a
central location, and util::task was the perfect place for it.

r? @pcwalton (or maybe someone else, I'm kinda sending you a bunch of
reviews today because I don't know who better to give them to)
This commit is contained in:
Clark Gaebel 2014-10-28 09:53:45 -07:00
parent 9e94ecf99c
commit 6df1cc8e4c
14 changed files with 48 additions and 36 deletions

View file

@ -15,6 +15,7 @@
// The only difference is that a normal channel is used instead of a sync_channel.
//
use task::spawn_named;
use std::sync::{Arc, Mutex};
pub struct TaskPool {
@ -28,9 +29,11 @@ impl TaskPool {
let state = Arc::new(Mutex::new(rx));
for _ in range(0, tasks) {
for i in range(0, tasks) {
let state = state.clone();
spawn(proc() worker(&*state));
spawn_named(
format!("TaskPoolWorker {}/{}", i+1, tasks),
proc() worker(&*state));
}
return TaskPool { tx: tx };
@ -50,4 +53,3 @@ impl TaskPool {
self.tx.send(job);
}
}