mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
9e94ecf99c
commit
6df1cc8e4c
14 changed files with 48 additions and 36 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue