1
Fork 0

core: Use PortOne instead of Future in future_result

This commit is contained in:
Brian Anderson 2012-10-22 19:01:37 -07:00
parent f6d2a71436
commit 3e4b2bd2b2
15 changed files with 21 additions and 23 deletions

View file

@ -642,7 +642,7 @@ pub mod tests {
// Have to get rid of our reference before blocking.
{ let _x = move x; } // FIXME(#3161) util::ignore doesn't work here
let res = option::swap_unwrap(&mut res);
future::get(&res);
res.recv();
}
#[test] #[should_fail] #[ignore(cfg(windows))]
@ -657,7 +657,7 @@ pub mod tests {
}
assert unwrap_exclusive(move x) == ~~"hello";
let res = option::swap_unwrap(&mut res);
future::get(&res);
res.recv();
}
#[test] #[ignore(cfg(windows))]

View file

@ -314,7 +314,7 @@ impl TaskBuilder {
* # Failure
* Fails if a future_result was already set for this task.
*/
fn future_result(blk: fn(v: future::Future<TaskResult>)) -> TaskBuilder {
fn future_result(blk: fn(v: Port<TaskResult>)) -> TaskBuilder {
// FIXME (#3725): Once linked failure and notification are
// handled in the library, I can imagine implementing this by just
// registering an arbitrary number of task::on_exit handlers and
@ -327,9 +327,7 @@ impl TaskBuilder {
// Construct the future and give it to the caller.
let (notify_pipe_ch, notify_pipe_po) = stream::<TaskResult>();
blk(do future::from_fn |move notify_pipe_po| {
notify_pipe_po.recv()
});
blk(move notify_pipe_po);
// Reconfigure self to use a notify channel.
TaskBuilder({
@ -482,7 +480,7 @@ impl TaskBuilder {
do fr_task_builder.spawn |move f| {
comm::send(ch, f());
}
match future::get(&option::unwrap(move result)) {
match option::unwrap(move result).recv() {
Success => result::Ok(comm::recv(po)),
Failure => result::Err(())
}
@ -899,14 +897,14 @@ fn test_add_wrapper() {
fn test_future_result() {
let mut result = None;
do task().future_result(|+r| { result = Some(move r); }).spawn { }
assert future::get(&option::unwrap(move result)) == Success;
assert option::unwrap(move result).recv() == Success;
result = None;
do task().future_result(|+r|
{ result = Some(move r); }).unlinked().spawn {
fail;
}
assert future::get(&option::unwrap(move result)) == Failure;
assert option::unwrap(move result).recv() == Failure;
}
#[test] #[should_fail] #[ignore(cfg(windows))]

View file

@ -651,7 +651,7 @@ mod tests {
}
// Wait for children to pass their asserts
for vec::each(children) |r| { future::get(r); }
for vec::each(children) |r| { r.recv(); }
// Wait for writer to finish
p.recv();

View file

@ -391,7 +391,7 @@ fn run_test(test: TestDesc, monitor_ch: comm::Chan<MonitorMsg>) {
task::task().unlinked().future_result(|+r| {
result_future = Some(move r);
}).spawn(move testfn);
let task_result = future::get(&option::unwrap(move result_future));
let task_result = option::unwrap(move result_future).recv();
let test_result = calc_result(&test, task_result == task::Success);
comm::send(monitor_ch, (copy test, test_result));
};

View file

@ -74,7 +74,7 @@ fn run(args: &[~str]) {
}
for vec::each(worker_results) |r| {
future::get(r);
r.recv();
}
//error!("sending stop message");

View file

@ -71,7 +71,7 @@ fn run(args: &[~str]) {
}
for vec::each(worker_results) |r| {
future::get(r);
r.recv();
}
//error!("sending stop message");

View file

@ -45,7 +45,7 @@ fn run(args: ~[~str]) {
};
}
for vec::each(worker_results) |r| {
future::get(r);
r.recv();
}
comm::send(to_child, stop);
let result = comm::recv(from_child);

View file

@ -78,7 +78,7 @@ fn stress(num_tasks: int) {
stress_task(i);
}
}
for results.each |r| { future::get(r); }
for results.each |r| { r.recv(); }
}
fn main() {

View file

@ -33,7 +33,7 @@ fn spawn_supervised_blocking(myname: &str, +f: fn~()) {
let mut res = None;
task::task().future_result(|+r| res = Some(move r)).supervised().spawn(move f);
error!("%s group waiting", myname);
let x = future::get(&option::unwrap(move res));
let x = option::unwrap(move res).recv();
assert x == task::Success;
}

View file

@ -19,7 +19,7 @@ fn test00() {
}
// Try joining tasks that have already finished.
future::get(&option::unwrap(move result));
option::unwrap(move result).recv();
debug!("Joined task.");
}

View file

@ -53,7 +53,7 @@ fn test00() {
}
// Join spawned tasks...
for results.each |r| { future::get(r); }
for results.each |r| { r.recv(); }
debug!("Completed: Final number is: ");
log(error, sum);

View file

@ -30,7 +30,7 @@ fn test00() {
i += 1;
}
future::get(&option::unwrap(move result));
option::unwrap(move result).recv();
assert (sum == number_of_messages * (number_of_messages - 1) / 2);
}

View file

@ -51,7 +51,7 @@ fn test00() {
while i < number_of_messages { sum += recv(po); i = i + 1; }
}
for results.each |r| { future::get(r); }
for results.each |r| { r.recv(); }
debug!("Completed: Final number is: ");
assert (sum ==
@ -134,7 +134,7 @@ fn test06() {
}
for results.each |r| { future::get(r); }
for results.each |r| { r.recv(); }
}

View file

@ -10,7 +10,7 @@ fn main() {
error!("2");
yield();
error!("3");
future::get(&option::unwrap(move result));
option::unwrap(move result).recv();
}
fn child() {

View file

@ -7,7 +7,7 @@ fn main() {
task::task().future_result(|+r| { result = Some(move r); }).spawn(child);
error!("1");
yield();
future::get(&option::unwrap(move result));
option::unwrap(move result).recv();
}
fn child() { error!("2"); }