diff options
| author | Jeff Olson <olson.jeffery@gmail.com> | 2012-08-23 22:49:09 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-09-08 14:22:15 -0700 |
| commit | d41af3e00229c2c32890360eb760219eeb14e724 (patch) | |
| tree | 58bf136385f0afdca4f5e47f57d654179df4534b /src/libcore | |
| parent | a8fc771f2004c376bbde68d09ead45d679f8f597 (diff) | |
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)
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/task.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/libcore/task.rs b/src/libcore/task.rs index ced0a9cef9b..24232c544ec 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -366,17 +366,22 @@ impl TaskBuilder { } // 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 { - match po.recv() { + match notify_pipe_po.recv() { Exit(_, result) => result } }); // Reconfigure self to use a notify channel. 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, .. *self.consume() }) @@ -445,12 +450,14 @@ impl TaskBuilder { * must be greater than zero. */ 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 } 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 = { linked: x.opts.linked, supervised: x.opts.supervised, @@ -522,7 +529,8 @@ impl TaskBuilder { let ch = comm::Chan(po); 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()); } match future::get(&option::unwrap(result)) { |
