From f6c552d6d7bcf06d6d30099ddf856364e3aef532 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Fri, 1 Jun 2012 16:19:48 -0700 Subject: [PATCH] Update task-killjoin-rsrc to use classes This test was xfailed, but I decided to update it to use classes anyway. The test currently compiles, but fails with a runtime error. So it's still xfailed. --- src/test/run-pass/task-killjoin-rsrc.rs | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 8f19fab4413..0696d176147 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -1,3 +1,4 @@ +// xfail-test // A port of task-killjoin to use a class with a dtor to manage // the join. @@ -5,23 +6,25 @@ use std; import task; -fn joinable(f: fn()) -> (task::task, comm::port) { - class notify { - let ch: comm::chan; let v: @mut bool; - new(ch: comm::chan, v: @mut bool) { self.ch = ch; self.v = v; } - drop { - #error["notify: task=%d v=%x unwinding=%b b=%b", +class notify { + let ch: comm::chan; let v: @mut bool; + new(ch: comm::chan, v: @mut bool) { self.ch = ch; self.v = v; } + drop { + #error["notify: task=%? v=%x unwinding=%b b=%b", task::get_task(), ptr::addr_of(*(self.v)) as uint, task::failing(), *(self.v)]; - comm::send(self.ch, *(self.v)); - } + let b = *(self.v); + comm::send(self.ch, b); } - fn wrapper(pair: (comm::chan, fn())) { +} + +fn joinable(f: fn~()) -> comm::port { + fn wrapper(+pair: (comm::chan, fn())) { let (c, f) = pair; let b = @mut false; - #error["wrapper: task=%d allocated v=%x", + #error["wrapper: task=%? allocated v=%x", task::get_task(), ptr::addr_of(*b) as uint]; let _r = notify(c, b); @@ -30,12 +33,11 @@ fn joinable(f: fn()) -> (task::task, comm::port) { } let p = comm::port(); let c = comm::chan(p); - let t = task::spawn {|| wrapper((c, f)) }; - ret (t, p); + let _ = task::spawn {|| wrapper((c, f)) }; + p } -fn join(pair: (task::task, comm::port)) -> bool { - let (_, port) = pair; +fn join(port: comm::port) -> bool { comm::recv(port) } @@ -43,22 +45,22 @@ fn supervised() { // Yield to make sure the supervisor joins before we // fail. This is currently not needed because the supervisor // runs first, but I can imagine that changing. - #error["supervised task=%d", task::get_task()]; + #error["supervised task=%?", task::get_task]; task::yield(); fail; } -fn supervisor() { +fn supervisor(b: task::builder) { // Unsupervise this task so the process doesn't return a failure status as // a result of the main task being killed. - task::unsupervise(); - #error["supervisor task=%d", task::get_task()]; + task::unsupervise(b); + #error["supervisor task=%?", task::get_task()]; let t = joinable(supervised); join(t); } fn main() { - join(joinable(supervisor)); + join(joinable({|| supervisor(task::builder())})); } // Local Variables: