core: fix breakage in TaskBuilder.future_result
the actual "fix" in this change is the chunk that moves `let x = self.consume()` to after the option dance that results in the `notify_chan` in TaskBuilder.try() the rest is cleanup/sense-making of what some of this code is doing (I'm looking at you, future_result)
This commit is contained in:
parent
a8fc771f20
commit
d41af3e002
1 changed files with 15 additions and 7 deletions
|
@ -366,17 +366,22 @@ impl TaskBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the future and give it to the caller.
|
// Construct the future and give it to the caller.
|
||||||
let (ch, po) = stream::<Notification>();
|
let (notify_pipe_ch, notify_pipe_po) = stream::<Notification>();
|
||||||
|
|
||||||
blk(do future::from_fn {
|
blk(do future::from_fn {
|
||||||
match po.recv() {
|
match notify_pipe_po.recv() {
|
||||||
Exit(_, result) => result
|
Exit(_, result) => result
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reconfigure self to use a notify channel.
|
// Reconfigure self to use a notify channel.
|
||||||
TaskBuilder({
|
TaskBuilder({
|
||||||
opts: { notify_chan: Some(ch),.. self.opts },
|
opts: {
|
||||||
|
linked: self.opts.linked,
|
||||||
|
supervised: self.opts.supervised,
|
||||||
|
mut notify_chan: Some(notify_pipe_ch),
|
||||||
|
sched: self.opts.sched
|
||||||
|
},
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
.. *self.consume()
|
.. *self.consume()
|
||||||
})
|
})
|
||||||
|
@ -445,12 +450,14 @@ impl TaskBuilder {
|
||||||
* must be greater than zero.
|
* must be greater than zero.
|
||||||
*/
|
*/
|
||||||
fn spawn(+f: fn~()) {
|
fn spawn(+f: fn~()) {
|
||||||
let x = self.consume();
|
let notify_chan = if self.opts.notify_chan == none {
|
||||||
let notify_chan = if self.opts.notify_chan == None {
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(option::swap_unwrap(&mut self.opts.notify_chan))
|
let swapped_notify_chan =
|
||||||
|
option::swap_unwrap(&mut self.opts.notify_chan);
|
||||||
|
some(swapped_notify_chan)
|
||||||
};
|
};
|
||||||
|
let x = self.consume();
|
||||||
let opts = {
|
let opts = {
|
||||||
linked: x.opts.linked,
|
linked: x.opts.linked,
|
||||||
supervised: x.opts.supervised,
|
supervised: x.opts.supervised,
|
||||||
|
@ -522,7 +529,8 @@ impl TaskBuilder {
|
||||||
let ch = comm::Chan(po);
|
let ch = comm::Chan(po);
|
||||||
let mut result = None;
|
let mut result = None;
|
||||||
|
|
||||||
do self.future_result(|+r| { result = Some(r); }).spawn {
|
let fr_task_builder = self.future_result(|+r| { result = Some(r); });
|
||||||
|
do fr_task_builder.spawn {
|
||||||
comm::send(ch, f());
|
comm::send(ch, f());
|
||||||
}
|
}
|
||||||
match future::get(&option::unwrap(result)) {
|
match future::get(&option::unwrap(result)) {
|
||||||
|
|
Loading…
Reference in a new issue