Skip to content

Commit 22de4a6

Browse files
committed
---
yaml --- r: 149184 b: refs/heads/try2 c: 21a064d h: refs/heads/master v: v3
1 parent bda1f84 commit 22de4a6

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: aaead93c4554b685935b70565fc1bb54edd945d6
8+
refs/heads/try2: 21a064d5a340a00042c81745cc7d2a65691e84be
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libgreen/task.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::cast;
2222
use std::rt::Runtime;
2323
use std::rt::rtio;
2424
use std::rt::local::Local;
25-
use std::rt::task::{Task, BlockedTask};
25+
use std::rt::task::{Task, BlockedTask, SendMessage};
2626
use std::task::TaskOpts;
2727
use std::unstable::mutex::Mutex;
2828

@@ -131,8 +131,7 @@ impl GreenTask {
131131
task.stdout = stdout;
132132
match notify_chan {
133133
Some(chan) => {
134-
let on_exit = proc(task_result) { chan.send(task_result) };
135-
task.death.on_exit = Some(on_exit);
134+
task.death.on_exit = Some(SendMessage(chan));
136135
}
137136
None => {}
138137
}

branches/try2/src/libnative/task.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::cast;
1818
use std::rt::env;
1919
use std::rt::local::Local;
2020
use std::rt::rtio;
21-
use std::rt::task::{Task, BlockedTask};
21+
use std::rt::task::{Task, BlockedTask, SendMessage};
2222
use std::rt::thread::Thread;
2323
use std::rt;
2424
use std::task::TaskOpts;
@@ -68,10 +68,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc()) {
6868
task.stderr = stderr;
6969
task.stdout = stdout;
7070
match notify_chan {
71-
Some(chan) => {
72-
let on_exit = proc(task_result) { chan.send(task_result) };
73-
task.death.on_exit = Some(on_exit);
74-
}
71+
Some(chan) => { task.death.on_exit = Some(SendMessage(chan)); }
7572
None => {}
7673
}
7774

branches/try2/src/libstd/rt/task.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use any::AnyOwnExt;
1717
use cast;
1818
use cleanup;
1919
use clone::Clone;
20+
use comm::Chan;
2021
use io::Writer;
2122
use iter::{Iterator, Take};
2223
use local_data;
@@ -67,11 +68,17 @@ pub enum BlockedTask {
6768
Shared(UnsafeArc<AtomicUint>),
6869
}
6970

71+
pub enum DeathAction {
72+
/// Action to be done with the exit code. If set, also makes the task wait
73+
/// until all its watched children exit before collecting the status.
74+
Execute(proc(TaskResult)),
75+
/// A channel to send the result of the task on when the task exits
76+
SendMessage(Chan<TaskResult>),
77+
}
78+
7079
/// Per-task state related to task death, killing, failure, etc.
7180
pub struct Death {
72-
// Action to be done with the exit code. If set, also makes the task wait
73-
// until all its watched children exit before collecting the status.
74-
on_exit: Option<proc(TaskResult)>,
81+
on_exit: Option<DeathAction>,
7582
}
7683

7784
pub struct BlockedTasks {
@@ -381,7 +388,8 @@ impl Death {
381388
/// Collect failure exit codes from children and propagate them to a parent.
382389
pub fn collect_failure(&mut self, result: TaskResult) {
383390
match self.on_exit.take() {
384-
Some(f) => f(result),
391+
Some(Execute(f)) => f(result),
392+
Some(SendMessage(ch)) => { ch.try_send(result); }
385393
None => {}
386394
}
387395
}

0 commit comments

Comments
 (0)