]> git.lizzy.rs Git - rust.git/commitdiff
port over the tests to use the new API
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 5 Jan 2012 05:14:53 +0000 (21:14 -0800)
committerNiko Matsakis <niko@alum.mit.edu>
Sat, 7 Jan 2012 06:40:31 +0000 (22:40 -0800)
57 files changed:
src/compiletest/compiletest.rs
src/compiletest/procsrv.rs
src/test/run-pass/basic-1.rs
src/test/run-pass/basic-2.rs
src/test/run-pass/basic.rs
src/test/run-pass/binops.rs
src/test/run-pass/chan-leak.rs
src/test/run-pass/child-outlives-parent.rs
src/test/run-pass/comm.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/issue-507.rs
src/test/run-pass/issue-687.rs
src/test/run-pass/issue-783.rs
src/test/run-pass/ivec-tag.rs
src/test/run-pass/join.rs
src/test/run-pass/lazychan.rs
src/test/run-pass/linked-failure.rs
src/test/run-pass/lots-a-fail.rs
src/test/run-pass/many.rs
src/test/run-pass/morestack5.rs
src/test/run-pass/morestack6.rs
src/test/run-pass/send-iloop.rs
src/test/run-pass/sendfn-generic-fn.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/spawn-module-qualified.rs
src/test/run-pass/spawn-types.rs
src/test/run-pass/spawn.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/task-comm-0.rs
src/test/run-pass/task-comm-1.rs
src/test/run-pass/task-comm-10.rs
src/test/run-pass/task-comm-11.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-15.rs
src/test/run-pass/task-comm-2.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-7.rs
src/test/run-pass/task-comm-8.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/task-comm-chan-cleanup4.rs
src/test/run-pass/task-comm.rs
src/test/run-pass/task-killjoin.rs
src/test/run-pass/task-life-0.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/threads.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unwind-box.rs
src/test/run-pass/unwind-resource.rs
src/test/run-pass/unwind-resource2.rs
src/test/run-pass/unwind-unique.rs
src/test/run-pass/yield.rs
src/test/run-pass/yield1.rs
src/test/stdtest/task.rs
src/test/stdtest/vec.rs

index d720c036d95dbf3f4aac27fd0124c10dbdc62d30..1193fa81131b59967075ec5bbde3df799b2ad33f 100644 (file)
@@ -193,21 +193,21 @@ fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn@()) ->
    test::joinable {
     testfn();
     let testfile = recv(configport);
-
-    ret task::spawn_joinable(
-        (cx.config, cx.procsrv.chan, testfile), run_test_task);
+    let (config, chan) = (cx.config, cx.procsrv.chan);
+    ret task::spawn_joinable {||
+        run_test_task(config, chan, testfile);
+    };
 }
 
-fn run_test_task(args: (common::config, procsrv::reqchan, [u8])) {
-
-    let (config, procsrv_chan, testfile) = args;
-
+fn run_test_task(config: common::config,
+                 procsrv_chan: procsrv::reqchan,
+                 testfile: [u8]) {
     test::configure_test_task();
 
     let procsrv = procsrv::from_chan(procsrv_chan);
     let cx = {config: config, procsrv: procsrv};
 
-    runtest::run(cx, testfile);
+    runtest::run(cx, copy testfile);
 }
 
 // Local Variables:
index 39ecb909a8585ca369a81f02c334153691343e0a..9029ee1bcea17406f7d7988dc31660708a25c5f1 100644 (file)
 
 fn mk() -> handle {
     let setupport = port();
-    let task = task::spawn_joinable(
-        chan(setupport),
-        fn (setupchan: chan<chan<request>>) {
-            let reqport = port();
-            let reqchan = chan(reqport);
-            send(setupchan, reqchan);
-            worker(reqport);
-        });
+    let setupchan = chan(setupport);
+    let task = task::spawn_joinable {||
+        let reqport = port();
+        let reqchan = chan(reqport);
+        send(setupchan, reqchan);
+        worker(reqport);
+    };
     ret {task: option::some(task), chan: recv(setupport)};
 }
 
index 1afb2cbd1ffbdb5383549174fecbf10b2e6d2be7..fb610279c77b7c60fda65d918d29723d9e35e507 100644 (file)
@@ -11,8 +11,9 @@
 
 fn main() {
     let p = port();
-    task::spawn(chan(p), a);
-    task::spawn(chan(p), a);
+    let ch = chan(p);
+    task::spawn {|| a(ch); };
+    task::spawn {|| a(ch); };
     let n: int = 0;
     n = recv(p);
     n = recv(p);
index 077109d616a238bbe51075c2e9ea68ab4c1cdf0b..6a238b4c4bcac4e537875ac44ebee93a25f46ff3 100644 (file)
@@ -2,6 +2,7 @@
 
 use std;
 import comm;
+import comm::port;
 import comm::send;
 import comm::chan;
 import comm::recv;
 fn a(c: chan<int>) { #debug("task a0"); #debug("task a1"); send(c, 10); }
 
 fn main() {
-    let p = comm::port();
-    task::spawn(chan(p), a);
-    task::spawn(chan(p), b);
+    let p = port();
+    let ch = chan(p);
+    task::spawn {|| a(ch); };
+    task::spawn {|| b(ch); };
     let n: int = 0;
     n = recv(p);
     n = recv(p);
index efeb8b88b156cf5c3d14bf6f11fa64017975ee03..323451c98abf0d2da1e4a414239c04f2fe5085ab 100644 (file)
@@ -31,8 +31,9 @@ fn main() {
     let n: int = 2 + 3 * 7;
     let s: str = "hello there";
     let p = comm::port();
-    task::spawn(chan(p), a);
-    task::spawn(chan(p), b);
+    let ch = comm::chan(p);
+    task::spawn {|| a(ch); };
+    task::spawn {|| b(ch); };
     let x: int = 10;
     x = g(n, s);
     log(debug, x);
index 56469dbb17262c71411aef3641c82a76a2814494..e5345f8a79eb265436e0529f6517e559743b53cf 100644 (file)
@@ -87,10 +87,10 @@ fn test_ptr() {
 }
 
 fn test_task() {
-    fn f(&&_i: ()) { }
+    fn f() { }
     let f1 = f, f2 = f;
-    let t1 = task::spawn((), f1);
-    let t2 = task::spawn((), f2);
+    let t1 = task::spawn {|| f1(); };
+    let t2 = task::spawn {|| f2(); };
 
     assert (t1 == t1);
     assert (t1 != t2);
index 171947050d80822632da717561cf81cd12fba618..f7adb1a0961dd531ba741c0a42a6f45827c60418 100644 (file)
@@ -23,7 +23,8 @@ fn request_task(c: chan<ctx>) {
 
 fn new() -> ctx {
     let p = port();
-    let t = task::spawn(chan(p), request_task);
+    let ch = chan(p);
+    let t = task::spawn {|| request_task(ch); };
     let cx: ctx;
     cx = recv(p);
     ret cx;
index 04940947145bc9deb83ed40cc104ecff6374cac6..4eabfa478a727d5ce1a0ba988506e2eb52bced32 100644 (file)
@@ -5,4 +5,4 @@
 
 fn child2(&&s: str) { }
 
-fn main() { let x = task::spawn("hi", child2); }
+fn main() { let x = task::spawn {|| child2("hi"); }; }
index 14b21a242bddd890f3054f4ebbefdcba7c7bc819..d3b648e44757db6c8b311b628d6edaca76cdd7aa 100644 (file)
@@ -9,7 +9,8 @@
 
 fn main() {
     let p = comm::port();
-    let t = task::spawn(chan(p), child);
+    let ch = comm::chan(p);
+    let t = task::spawn {|| child(ch); };
     let y = recv(p);
     #error("received");
     log(error, y);
index 8670a53ac335e11befacc9bd6a9b7528fe723a63..5c6e14e93a852c02d901c5ca6efa8e5a088676d2 100644 (file)
@@ -33,12 +33,12 @@ mod map_reduce {
     tag ctrl_proto { find_reducer([u8], chan<int>); mapper_done; }
 
     fn start_mappers(ctrl: chan<ctrl_proto>, inputs: [str]) {
-        for i: str in inputs { task::spawn((ctrl, i), map_task); }
+        for i: str in inputs {
+            task::spawn {|| map_task(ctrl, i); };
+        }
     }
 
-    fn map_task(&&args: (chan<ctrl_proto>, str)) {
-        let (ctrl, input) = args;
-
+    fn map_task(ctrl: chan<ctrl_proto>, input: str) {
         let intermediates = map::new_str_hash();
 
         fn emit(im: map::hashmap<str, int>, ctrl: chan<ctrl_proto>, key: str,
index 716b9dd16db0fb9402dff5a1a9fce0e665ea249e..3cb790063a97868d1d47018684677b1331f64bac 100644 (file)
 fn grandchild(c: chan<int>) { send(c, 42); }
 
 fn child(c: chan<int>) {
-    let _grandchild = task::spawn_joinable(copy c, grandchild);
+    let _grandchild = task::spawn_joinable {|| grandchild(c); };
     join(_grandchild);
 }
 
 fn main() {
     let p = comm::port();
+    let ch = chan(p);
 
-    let _child = task::spawn_joinable(chan(p), child);
+    let _child = task::spawn_joinable {|| child(ch); };
 
     let x: int = recv(p);
 
index 2c0a2ae7afc719547bd65d81c59d959a5fc2b690..8ff6b4bab27f778d5b44637a9544084693dcf842 100644 (file)
@@ -15,8 +15,7 @@ fn producer(c: chan<[u8]>) {
     send(c, empty);
 }
 
-fn packager(&&args: (chan<chan<[u8]>>, chan<msg>)) {
-    let (cb, msg) = args;
+fn packager(cb: chan<chan<[u8]>>, msg: chan<msg>) {
     let p: port<[u8]> = port();
     send(cb, chan(p));
     while true {
@@ -39,11 +38,13 @@ fn packager(&&args: (chan<chan<[u8]>>, chan<msg>)) {
 
 fn main() {
     let p: port<msg> = port();
+    let ch = chan(p);
     let recv_reader: port<chan<[u8]>> = port();
-    let pack = task::spawn((chan(recv_reader), chan(p)), packager);
+    let recv_reader_chan = chan(recv_reader);
+    let pack = task::spawn {|| packager(recv_reader_chan, ch); };
 
     let source_chan: chan<[u8]> = recv(recv_reader);
-    let prod = task::spawn(source_chan, producer);
+    let prod = task::spawn {|| producer(source_chan); };
 
     while true {
         let msg = recv(p);
index 086e652932084fd242d8862ce2635e8a8483c3e0..27384b102ebd2dc48afb5f314000d6c4a5a2e660 100644 (file)
@@ -2,14 +2,15 @@
 import comm::*;
 import task::*;
 
-fn a(&&_args: ()) {
+fn a() {
     fn doit() {
         fn b(c: chan<chan<int>>) {
             let p = port();
             send(c, chan(p));
         }
         let p = port();
-        spawn(chan(p), b);
+        let ch = chan(p);
+        spawn {|| b(ch); };
         recv(p);
     }
     let i = 0;
@@ -20,6 +21,6 @@ fn b(c: chan<chan<int>>) {
 }
 
 fn main() {
-    let t = spawn_joinable((), a);
+    let t = spawn_joinable {|| a(); };
     join(t);
 }
index 41b06d9294c7f15772a6b4401302a9846365e6d5..dce947bb6227cbc1a3aa458b41368e0666aa7e7a 100644 (file)
@@ -15,7 +15,8 @@ fn producer(c: chan<[u8]>) {
 
 fn main() {
     let p: port<[u8]> = port();
-    let prod = task::spawn(chan(p), producer);
+    let ch = chan(p);
+    let prod = task::spawn {|| producer(ch); };
 
     let data: [u8] = recv(p);
 }
index 7652eb3e1d731dbc2ecf9980980346ecbfd5a4fb..ef4073406b4babaffb8128c2ee107649cf071f2f 100644 (file)
@@ -5,11 +5,11 @@
 import task::*;
 
 fn main() {
-    let other = spawn_joinable((), child);
+    let other = spawn_joinable {|| child(); };
     #error("1");
     yield();
     join(other);
     #error("3");
 }
 
-fn child(&&_i: ()) { #error("2"); }
+fn child() { #error("2"); }
index 67ec699e070105b2c9280cf43b5df1dc3a8fe5af..2e6042096187fa174f7a248503c08d25cc734bc3 100644 (file)
@@ -6,15 +6,16 @@
 
 fn main() {
     let p = port();
+    let ch = chan(p);
     let y: int;
 
-    task::spawn(chan(p), child);
+    task::spawn {|| child(ch); };
     y = recv(p);
     #debug("received 1");
     log(debug, y);
     assert (y == 10);
 
-    task::spawn(chan(p), child);
+    task::spawn {|| child(ch); };
     y = recv(p);
     #debug("received 2");
     log(debug, y);
index 7e9b1571efe3f68e39225e87badbfb9ffa7ea4b4..b82aa7c2cb0a78c3b9242a3cb72e1c63bf1bb28e 100644 (file)
@@ -5,17 +5,17 @@
 import comm::port;
 import comm::recv;
 
-fn child(&&_i: ()) { assert (1 == 2); }
+fn child() { assert (1 == 2); }
 
-fn parent(&&_i: ()) {
+fn parent() {
     // Since this task isn't supervised it won't bring down the whole
     // process
     task::unsupervise();
     let p = port::<int>();
-    task::spawn((), child);
+    task::spawn {|| child(); };
     let x = recv(p);
 }
 
 fn main() {
-    task::spawn((), parent);
+    task::spawn {|| parent(); };
 }
\ No newline at end of file
index f2f83a9b3d9c3962f4b80d493250660121606e26..9f51b688b11f6d26856118d854da53353512a0d7 100644 (file)
@@ -4,17 +4,17 @@
 import comm;
 import uint;
 
-fn die(&&_i: ()) {
+fn die() {
     fail;
 }
 
-fn iloop(&&_i: ()) {
+fn iloop() {
     task::unsupervise();
-    task::spawn((), die);
+    task::spawn {|| die(); };
 }
 
 fn main() {
     uint::range(0u, 100u) {|_i|
-        task::spawn((), iloop);
+        task::spawn {|| iloop(); };
     }
 }
\ No newline at end of file
index 044e77d5f1e153dc6bb8b3c47801c9709545a548..0914e059b95920914606215794a8565befeeb48d 100644 (file)
@@ -4,13 +4,13 @@
 import task;
 import comm;
 
-fn sub(&&args: (comm::chan<int>, int)) {
-    let (parent, id) = args;
+fn sub(parent: comm::chan<int>, id: int) {
     if id == 0 {
         comm::send(parent, 0);
     } else {
         let p = comm::port();
-        let child = task::spawn((comm::chan(p), id - 1), sub);
+        let ch = comm::chan(p);
+        let child = task::spawn {|| sub(ch, id - 1); };
         let y = comm::recv(p);
         comm::send(parent, y + 1);
     }
@@ -18,7 +18,8 @@ fn sub(&&args: (comm::chan<int>, int)) {
 
 fn main() {
     let p = comm::port();
-    let child = task::spawn((comm::chan(p), 200), sub);
+    let ch = comm::chan(p);
+    let child = task::spawn {|| sub(ch, 200); };
     let y = comm::recv(p);
     #debug("transmission complete");
     log(debug, y);
index aab001c562905be6d27e10646d7634cbb191d130..6c1d906e1e6cfcbfcbf87fdaef04f445801aea96 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
     let sz = 400u;
     while sz < 500u {
         rustrt::set_min_stack(sz);
-        task::join(task::spawn_joinable(200, getbig));
+        task::join(task::spawn_joinable {|| getbig(200) });
         sz += 1u;
     }
 }
\ No newline at end of file
index c72d4f98228236810dbd5ecf4c9716a52c42cef7..05c3e3831269d7b499d3cc212bddeed734883586 100644 (file)
 fn calllink09() { rustrt::sched_threads(); }
 fn calllink10() { rustrt::rust_get_task(); }
 
-fn runtest(&&args:(fn(), u32)) {
-    let (f, frame_backoff) = args;
+fn runtest(f: sendfn(), frame_backoff: u32) {
     runtest2(f, frame_backoff, 0 as *u8);
 }
 
-fn runtest2(f: fn(), frame_backoff: u32, last_stk: *u8) -> u32 {
+fn runtest2(f: sendfn(), frame_backoff: u32, last_stk: *u8) -> u32 {
     let curr_stk = rustrt::debug_get_stk_seg();
     if (last_stk != curr_stk && last_stk != 0 as *u8) {
         // We switched stacks, go back and try to hit the dynamic linker
@@ -73,6 +72,6 @@ fn main() {
         let sz = rng.next() % 256u32 + 256u32;
         let frame_backoff = rng.next() % 10u32 + 1u32;
         rustrt::set_min_stack(sz as uint);
-        task::join(task::spawn_joinable((f, frame_backoff), runtest));
+        task::join(task::spawn_joinable {|| runtest(f, frame_backoff);});
     }
 }
\ No newline at end of file
index b119ac6eb1d21064a6db5651357b6c11d0fe5448..5fb4e4e9bd9e43293bdfd186935e6b11f469b7e3 100644 (file)
@@ -4,13 +4,13 @@
 import comm;
 import uint;
 
-fn die(&&_i: ()) {
+fn die() {
     fail;
 }
 
-fn iloop(&&_i: ()) {
+fn iloop() {
     task::unsupervise();
-    task::spawn((), die);
+    task::spawn {|| die(); };
     let p = comm::port::<()>();
     let c = comm::chan(p);
     while true {
@@ -23,6 +23,6 @@ fn iloop(&&_i: ()) {
 
 fn main() {
     uint::range(0u, 16u) {|_i|
-        task::spawn((), iloop);
+        task::spawn {|| iloop(); };
     }
 }
\ No newline at end of file
index 66177fd04aecd36b5e410df0bc142540f52d2dda..0a53d529d38dc1246a6b8463c1ad4351c50c8394 100644 (file)
@@ -28,7 +28,7 @@ fn spawn<A: copy, B: copy>(f: fn(sendfn(A,B)->pair<A,B>)) {
     let arg = sendfn(a: A, b: B) -> pair<A,B> {
         ret make_generic_record(a, b);
     };
-    task::spawn(arg, f);
+    task::spawn {|| f(arg); };
 }
 
 fn test05() {
index 84bc0759502114ca08517f515987b8efdf3673b3..281a438b7ba31652c6d22e4e489275280b4f17c5 100644 (file)
@@ -16,5 +16,7 @@ fn test05() {
         log(error, *three + n); // will copy x into the closure
         assert(*three == 3);
     };
-    task::spawn(fn_to_send, test05_start);
+    task::spawn(sendfn[move fn_to_send]() {
+        test05_start(fn_to_send);
+    });
 }
index 68e0f22f2f83ebaf3d6fbea2568cd144149fa828..92c6613c0fd2abb020551ebc3818f42161abd9bc 100644 (file)
@@ -4,15 +4,15 @@
 import task::yield;
 import task;
 
-fn x(&&args: (str, int)) {
-    let (s, n) = args;
-    log(debug, s); log(debug, n);
+fn x(s: str, n: int) {
+    log(debug, s);
+    log(debug, n);
 }
 
 fn main() {
-    task::spawn(("hello from first spawned fn", 65), x);
-    task::spawn(("hello from second spawned fn", 66), x);
-    task::spawn(("hello from third spawned fn", 67), x);
+    task::spawn {|| x("hello from first spawned fn", 65); };
+    task::spawn {|| x("hello from second spawned fn", 66); };
+    task::spawn {|| x("hello from third spawned fn", 67); };
     let i: int = 30;
     while i > 0 { i = i - 1; #debug("parent sleeping"); yield(); }
 }
index 413474efd929f4a0d272085f0af1483655f307c1..cbc3b8b2ea64b5c700a34f121c43fdbf8beff6ac 100644 (file)
@@ -2,7 +2,7 @@
 import task::join;
 import task::spawn_joinable;
 
-fn main() { let x = spawn_joinable(10, m::child); join(x); }
+fn main() { let x = spawn_joinable {|| m::child(10); }; join(x); }
 
 mod m {
     fn child(&&i: int) { log(debug, i); }
index fe6ea6374b13b81726fc456628b3cee5ac0deb0c..727d8326b4ea28f8fe53164ead9629c1a2f9e6c6 100644 (file)
 
 type ctx = comm::chan<int>;
 
-fn iotask(&&args: (ctx, str)) {
-    let (cx, ip) = args;
+fn iotask(cx: ctx, ip: str) {
     assert (str::eq(ip, "localhost"));
 }
 
 fn main() {
     let p = comm::port::<int>();
-    task::spawn((comm::chan(p), "localhost"), iotask);
+    let ch = comm::chan(p);
+    task::spawn {|| iotask(ch, "localhost"); };
 }
index 52ceb4c27abef239553db7029e5008153d1ae7af..7a395f677aa68e395f3d6bd66cd2e1c32a012919 100644 (file)
@@ -4,7 +4,10 @@
 
 import task;
 
-fn main() { let t = task::spawn_joinable(10, child); task::join(t); }
+fn main() {
+    let t = task::spawn_joinable {|| child(10); };
+    task::join(t);
+}
 
 fn child(&&i: int) { log(error, i); assert (i == 10); }
 
index 6d22149824fd89b09d5dfc2fe26a63283e6818d0..86e2c9965176a242bc999e920f0d4ea5e9315012 100644 (file)
@@ -3,7 +3,7 @@
 use std;
 import task::spawn;
 
-fn main() { spawn((10, 20, 30, 40, 50, 60, 70, 80, 90), child); }
+fn main() { spawn {|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)); }; }
 
 fn child(&&args: (int, int, int, int, int, int, int, int, int)) {
     let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
index d54b31b07b512bcd751e4fe1337ed12bf2576f94..0d0a70ae816c8d2fa1f31fac560199582997308d 100644 (file)
@@ -20,7 +20,7 @@ fn test05_start(ch : chan<int>) {
 fn test05() {
     let po = comm::port();
     let ch = comm::chan(po);
-    task::spawn(ch, test05_start);
+    task::spawn {|| test05_start(ch); };
     let value = comm::recv(po);
     log(error, value);
     value = comm::recv(po);
index 478eb3292ea40adcf9ace45c20f700e3444f765d..96901b9ae56808b8c6d013468ecea254b4e2a766 100644 (file)
@@ -5,10 +5,10 @@
 
 fn main() { test00(); }
 
-fn start(&&_i: ()) { #debug("Started / Finished task."); }
+fn start() { #debug("Started / Finished task."); }
 
 fn test00() {
-    let t = spawn_joinable((), start);
+    let t = spawn_joinable {|| start(); };
     join(t);
     #debug("Completing.");
 }
index 84e4825ec9be0f742b59bcb8c061edb1b86f039d..d3c1d19f3eb0b319fa199382a440bc74fe59dbdb 100644 (file)
@@ -18,7 +18,8 @@ fn start(c: comm::chan<comm::chan<str>>) {
 
 fn main() {
     let p = comm::port();
-    let child = task::spawn(comm::chan(p), start);
+    let ch = comm::chan(p);
+    let child = task::spawn {|| start(ch); };
 
     let c = comm::recv(p);
     comm::send(c, "A");
index d8f3d12d059b9747b0e14241fc81fe3055468aca..b1e23b2443a95c74af5d62c4b7ce18150d190858 100644 (file)
@@ -9,6 +9,7 @@ fn start(c: comm::chan<comm::chan<int>>) {
 
 fn main() {
     let p = comm::port();
-    let child = task::spawn(comm::chan(p), start);
+    let ch = comm::chan(p);
+    let child = task::spawn {|| start(ch); };
     let c = comm::recv(p);
 }
index 2f6adfea5dc36444a827be670545e70aa3ef17fe..f92585cd2542793af106b8ff48d84c52bcd1928b 100644 (file)
@@ -7,7 +7,7 @@
 
 fn test00() {
     let i: int = 0;
-    let t = task::spawn_joinable(i, start);
+    let t = task::spawn_joinable {|| start(i); };
 
     // Sleep long enough for the task to finish.
     task::sleep(10000u);
index c2a15229f88778ffc12c10f6f0ca122aec5c956b..dc2393d13f481b055fdaefcaed73916ef09c3d06 100644 (file)
@@ -3,8 +3,7 @@
 import comm;
 import comm::send;
 
-fn start(&&args: (comm::chan<int>, int, int)) {
-    let (c, start, number_of_messages) = args;
+fn start(c: comm::chan<int>, start: int, number_of_messages: int) {
     let i: int = 0;
     while i < number_of_messages { send(c, start + i); i += 1; }
 }
@@ -12,7 +11,8 @@ fn start(&&args: (comm::chan<int>, int, int)) {
 fn main() {
     #debug("Check that we don't deadlock.");
     let p = comm::port::<int>();
-    let a = task::spawn_joinable((comm::chan(p), 0, 10), start);
+    let ch = comm::chan(p);
+    let a = task::spawn_joinable {|| start(ch, 0, 10); };
     task::join(a);
     #debug("Joined task");
 }
index e37eb15ce39e74c16f0314bcf23e3e02ea741f10..48f4ca7a8b24b1d0c6b2ddb3c9af69af240103d1 100644 (file)
@@ -4,12 +4,13 @@
 
 fn main() {
     let po = comm::port::<int>();
+    let ch = comm::chan(po);
 
     // Spawn 10 tasks each sending us back one int.
     let i = 10;
     while (i > 0) {
         log(debug, i);
-        task::spawn((i, comm::chan(po)), child);
+        task::spawn {|| child(i, ch); };
         i = i - 1;
     }
 
@@ -27,8 +28,7 @@ fn main() {
     #debug("main thread exiting");
 }
 
-fn child(&&args: (int, comm::chan<int>)) {
-    let (x, ch) = args;
+fn child(x: int, ch: comm::chan<int>) {
     log(debug, x);
-    comm::send(ch, x);
+    comm::send(ch, copy x);
 }
index c526f54203d50acd97226cfe601f3ff044751f89..d762b7fca903b4907aa0bedd52988852c2676cd5 100644 (file)
@@ -3,10 +3,12 @@
 import comm;
 import task;
 
-fn start(&&args: (comm::chan<int>, int)) {
-    let (c, i) = args;
-
-    while i > 0 { comm::send(c, 0); i = i - 1; }
+fn start(c: comm::chan<int>, i0: int) {
+    let i = i0;
+    while i > 0 {
+        comm::send(c, 0);
+        i = i - 1;
+    }
 }
 
 fn main() {
@@ -15,6 +17,7 @@ fn main() {
     // is likely to terminate before the child completes, so from
     // the child's point of view the receiver may die. We should
     // drop messages on the floor in this case, and not crash!
-    let child = task::spawn((comm::chan(p), 10), start);
+    let ch = comm::chan(p);
+    let child = task::spawn {|| start(ch, 10); };
     let c = comm::recv(p);
 }
index 6ad262bc3ab79b326eadedf807d5ee2703b0f4ff..c17b1c8a11e61691bacfaaa7ecb202d2ac807caa 100644 (file)
@@ -22,7 +22,7 @@ fn test00() {
     let tasks = [];
     while i < number_of_tasks {
         i = i + 1;
-        tasks += [task::spawn_joinable(copy i, start)];
+        tasks += [task::spawn_joinable {|| start(i); }];
     }
 
     for t in tasks { task::join(t); }
index 407939c9e657100c9032ae8ff84daa53b291317b..d582630935679d6e99e8d60c2f01fc81872ca676 100644 (file)
@@ -7,8 +7,7 @@
 
 fn main() { #debug("===== WITHOUT THREADS ====="); test00(); }
 
-fn test00_start(&&args: (chan<int>, int, int)) {
-    let (ch, message, count) = args;
+fn test00_start(ch: chan<int>, message: int, count: int) {
     #debug("Starting test00_start");
     let i: int = 0;
     while i < count {
@@ -33,8 +32,9 @@ fn test00() {
     // Create and spawn tasks...
     let tasks = [];
     while i < number_of_tasks {
-        tasks += [task::spawn_joinable(
-            (ch, i, number_of_messages), test00_start)];
+        tasks += [task::spawn_joinable {||
+            test00_start(ch, i, number_of_messages)
+        }];
         i = i + 1;
     }
 
index 07b82a179875680f9f115c3af9e7d0225810c9da..c7c15830955268017aa4bef39408da95dc0c8e18 100644 (file)
@@ -7,8 +7,7 @@
 
 fn main() { test00(); }
 
-fn test00_start(&&args: (comm::chan<int>, int, int)) {
-    let (c, start, number_of_messages) = args;
+fn test00_start(c: comm::chan<int>, start: int, number_of_messages: int) {
     let i: int = 0;
     while i < number_of_messages { comm::send(c, start + i); i += 1; }
 }
@@ -18,23 +17,20 @@ fn test00() {
     let sum: int = 0;
     let p = port();
     let number_of_messages: int = 10;
+    let c = chan(p);
 
-    let t0 =
-        task::spawn_joinable((chan(p),
-                               number_of_messages * 0,
-                               number_of_messages), test00_start);
-    let t1 =
-        task::spawn_joinable((chan(p),
-                               number_of_messages * 1,
-                               number_of_messages), test00_start);
-    let t2 =
-        task::spawn_joinable((chan(p),
-                               number_of_messages * 2,
-                               number_of_messages), test00_start);
-    let t3 =
-        task::spawn_joinable((chan(p),
-                               number_of_messages * 3,
-                               number_of_messages), test00_start);
+    let t0 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 0, number_of_messages);
+    };
+    let t1 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 1, number_of_messages);
+    };
+    let t2 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 2, number_of_messages);
+    };
+    let t3 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 3, number_of_messages);
+    };
 
     let i: int = 0;
     while i < number_of_messages {
index bd2cc06cd4b9e7c9d96c606184d0d5321133a84b..8259fde9fad13d984d0130c794cc1154bb2faa88 100644 (file)
@@ -4,8 +4,7 @@
 
 fn main() { test00(); }
 
-fn test00_start(&&args: (comm::chan<int>, int, int)) {
-    let (c, start, number_of_messages) = args;
+fn test00_start(c: comm::chan<int>, start: int, number_of_messages: int) {
     let i: int = 0;
     while i < number_of_messages { comm::send(c, start + i); i += 1; }
 }
@@ -14,24 +13,21 @@ fn test00() {
     let r: int = 0;
     let sum: int = 0;
     let p = comm::port();
+    let c = comm::chan(p);
     let number_of_messages: int = 10;
 
-    let t0 =
-        task::spawn_joinable((comm::chan(p),
-                               number_of_messages * 0,
-                               number_of_messages), test00_start);
-    let t1 =
-        task::spawn_joinable((comm::chan(p),
-                               number_of_messages * 1,
-                               number_of_messages), test00_start);
-    let t2 =
-        task::spawn_joinable((comm::chan(p),
-                               number_of_messages * 2,
-                               number_of_messages), test00_start);
-    let t3 =
-        task::spawn_joinable((comm::chan(p),
-                               number_of_messages * 3,
-                               number_of_messages), test00_start);
+    let t0 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 0, number_of_messages);
+    };
+    let t1 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 1, number_of_messages);
+    };
+    let t2 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 2, number_of_messages);
+    };
+    let t3 = task::spawn_joinable {||
+        test00_start(c, number_of_messages * 3, number_of_messages);
+    };
 
     let i: int = 0;
     while i < number_of_messages {
index 703fb3fc2a0112c8d27541de5bb37cd5abefffd9..f6cc1dae6f017f08896cf30b118c352c637d0bef 100644 (file)
@@ -4,8 +4,7 @@
 
 fn main() { test00(); }
 
-fn test00_start(&&args: (comm::chan<int>, int)) {
-    let (c, number_of_messages) = args;
+fn test00_start(c: comm::chan<int>, number_of_messages: int) {
     let i: int = 0;
     while i < number_of_messages { comm::send(c, i + 0); i += 1; }
 }
@@ -15,9 +14,11 @@ fn test00() {
     let sum: int = 0;
     let p = comm::port();
     let number_of_messages: int = 10;
+    let ch = comm::chan(p);
 
-    let t0 = task::spawn_joinable((comm::chan(p), number_of_messages),
-                                  test00_start);
+    let t0 = task::spawn_joinable {||
+        test00_start(ch, number_of_messages);
+    };
 
     let i: int = 0;
     while i < number_of_messages {
index d7553afb8bb1f52c3859426dcc0a4f4d15cd9784..4593c90293a21e7839bb2e10ef720e4ab64fe8f5 100644 (file)
@@ -12,16 +12,17 @@ fn starship(&&ch: comm::chan<str>) {
     }
 }
 
-fn starbase(&&_args: ()) {
+fn starbase() {
     int::range(0, 10) { |_i|
         let p = comm::port();
-        task::spawn(comm::chan(p), starship);
+        let c = comm::chan(p);
+        task::spawn {|| starship(c);};
         task::yield();
     }
 }
 
 fn main() {
     int::range(0, 10) { |_i|
-        task::spawn((), starbase);
+        task::spawn {|| starbase();};
     }
 }
\ No newline at end of file
index 85a9fb8dfbda4c57a1584d74f93796bb6a6d2226..bd9d359383c2d8f64ccddfa915bbcdc111369b5d 100644 (file)
@@ -18,8 +18,7 @@ fn main() {
     test06();
 }
 
-fn test00_start(&&args: (chan<int>, int, int)) {
-    let (ch, message, count) = args;
+fn test00_start(ch: chan<int>, message: int, count: int) {
     #debug("Starting test00_start");
     let i: int = 0;
     while i < count {
@@ -43,8 +42,9 @@ fn test00() {
     let tasks = [];
     while i < number_of_tasks {
         i = i + 1;
-        tasks += [task::spawn_joinable(
-            (ch, i, number_of_messages), test00_start)];
+        tasks += [
+            task::spawn_joinable {|| test00_start(ch, i, number_of_messages);}
+        ];
     }
     let sum: int = 0;
     for t in tasks {
@@ -90,7 +90,7 @@ fn test03() {
     log(debug, v.length());
 }
 
-fn test04_start(&&_args: ()) {
+fn test04_start() {
     #debug("Started task");
     let i: int = 1024 * 1024;
     while i > 0 { i = i - 1; }
@@ -100,7 +100,7 @@ fn test04_start(&&_args: ()) {
 fn test04() {
     #debug("Spawning lots of tasks.");
     let i: int = 4;
-    while i > 0 { i = i - 1; task::spawn((), test04_start); }
+    while i > 0 { i = i - 1; task::spawn {|| test04_start(); }; }
     #debug("Finishing up.");
 }
 
@@ -115,7 +115,7 @@ fn test05_start(ch: chan<int>) {
 fn test05() {
     let po = comm::port();
     let ch = chan(po);
-    task::spawn(ch, test05_start);
+    task::spawn {|| test05_start(ch); };
     let value: int;
     value = recv(po);
     value = recv(po);
@@ -139,7 +139,7 @@ fn test06() {
     let tasks = [];
     while i < number_of_tasks {
         i = i + 1;
-        tasks += [task::spawn_joinable(copy i, test06_start)];
+        tasks += [task::spawn_joinable {|| test06_start(i);}];
     }
 
 
index a4ba23ef925d60fe457a7721815358ce9a9ccac2..313d9bd37029cf0d3eb49553d04295606b4472a4 100644 (file)
@@ -9,7 +9,7 @@
 use std;
 import task;
 
-fn supervised(&&_args: ()) {
+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.
@@ -17,17 +17,17 @@ fn supervised(&&_args: ()) {
     fail;
 }
 
-fn supervisor(&&_args: ()) {
+fn supervisor() {
     // Unsupervise this task so the process doesn't return a failure status as
     // a result of the main task being killed.
     task::unsupervise();
     let f = supervised;
-    let t = task::spawn_joinable((), supervised);
+    let t = task::spawn_joinable {|| supervised(); };
     task::join(t);
 }
 
 fn main() {
-    let dom2 = task::spawn_joinable((), supervisor);
+    let dom2 = task::spawn_joinable {|| supervisor(); };
     task::join(dom2);
 }
 
index 47afb2aec5f6bd7f5dff0fa3b3a42961cbc672de..1aead2837581c3c79775e6427ad056a2b1ec65d0 100644 (file)
@@ -1,6 +1,8 @@
 use std;
 import task;
-fn main() { task::spawn("Hello", child); }
+fn main() {
+    task::spawn {|| child("Hello"); };
+}
 
 fn child(&&s: str) {
 
index f3fdeea259b9c42bb6d98f55e088cd299ee89ac9..23597b3ed626b960a13d9bf6752960d183d5f3dd 100644 (file)
 fn test_ret() { let x: @int = ret; }
 
 fn test_fail() {
-    fn f(&&_i: ()) { task::unsupervise(); let x: @int = fail; }
-    task::spawn((), f);
+    fn f() { task::unsupervise(); let x: @int = fail; }
+    task::spawn {|| f(); };
 }
 
 fn test_fail_indirect() {
     fn f() -> ! { fail; }
-    fn g(&&_i: ()) { task::unsupervise(); let x: @int = f(); }
-    task::spawn((), g);
+    fn g() { task::unsupervise(); let x: @int = f(); }
+    task::spawn {|| g(); };
 }
 
 fn main() {
index 2f09d1c6b4fd48930c8da4c9a455b06ab09b169d..9f4e6e1fdd84fea4e2c5adb2e7c779f706dd9b8f 100644 (file)
@@ -5,7 +5,7 @@
 
 fn main() {
     let i = 10;
-    while i > 0 { task::spawn(copy i, child); i = i - 1; }
+    while i > 0 { task::spawn {|| child(i); }; i = i - 1; }
     #debug("main thread exiting");
 }
 
index 1625e7cc9c174d7076a20567e21c951445a1f3b2..976ca32104e95d3aa60d4233da8f3268b9bd9b91 100644 (file)
@@ -3,17 +3,17 @@
 import task;
 import uint;
 
-fn child(args: (comm::chan<~uint>, uint)) {
-    let (c, i) = args;
+fn child(c: comm::chan<~uint>, i: uint) {
     comm::send(c, ~i);
 }
 
 fn main() {
     let p = comm::port();
+    let ch = comm::chan(p);
     let n = 100u;
     let expected = 0u;
     uint::range(0u, n) {|i|
-        task::spawn((comm::chan(p), i), child);
+        task::spawn {|| child(ch, i); };
         expected += i;
     }
 
index 9cfcd5f5c55e2e241578dd0acda8c5fe9facc0d1..ca4221e07632b1ad425d448e2b82051daef4db67 100644 (file)
@@ -2,12 +2,12 @@
 use std;
 import task;
 
-fn f(&&_i: ()) {
+fn f() {
     task::unsupervise();
     let a = @0;
     fail;
 }
 
 fn main() {
-    task::spawn((), f);
+    task::spawn {|| f(); };
 }
\ No newline at end of file
index eaaee443cfc8b76d60dc35de038d7642f34cd932..5bb70236b7c63d71311ff6d61c224c7f792ae236 100644 (file)
@@ -16,6 +16,6 @@ fn f(c: comm::chan<bool>) {
 fn main() {
     let p = comm::port();
     let c = comm::chan(p);
-    task::spawn(c, f);
+    task::spawn {|| f(c); };
     assert comm::recv(p);
 }
\ No newline at end of file
index 3d55982a5bb039e6caeaba05de754b0d09ebe5e5..dbf91f31a3f2d34b441c1db6c9722e6b991e0a2e 100644 (file)
@@ -6,12 +6,12 @@
 resource complainer(c: @int) {
 }
 
-fn f(&&_i: ()) {
+fn f() {
     task::unsupervise();
     let c <- complainer(@0);
     fail;
 }
 
 fn main() {
-    task::spawn((), f);
+    task::spawn {|| f(); };
 }
\ No newline at end of file
index 40005d733f515bb091fbddc94f38d1ea83cd3adc..9fab3c5460921f5f70cf77a75ac75c032db0fae7 100644 (file)
@@ -2,12 +2,12 @@
 use std;
 import task;
 
-fn f(&&_i: ()) {
+fn f() {
     task::unsupervise();
     let a = ~0;
     fail;
 }
 
 fn main() {
-    task::spawn((), f);
+    task::spawn {|| f(); };
 }
\ No newline at end of file
index 43cfecf2045e944eb32251114b0468f68b3613a1..eb4a74c141abd9f020b6f9eb10d7c33a5d0506bb 100644 (file)
@@ -4,7 +4,7 @@
 import task::*;
 
 fn main() {
-    let other = task::spawn_joinable((), child);
+    let other = task::spawn_joinable {|| child(); };
     #error("1");
     yield();
     #error("2");
@@ -13,6 +13,6 @@ fn main() {
     join(other);
 }
 
-fn child(&&_i: ()) {
+fn child() {
     #error("4"); yield(); #error("5"); yield(); #error("6");
 }
index 3b4795a47a12ea03f05efd7057aec703ba2a3594..a5234cf8d129fbfb2f94aeb815f7739e06ea3e05 100644 (file)
@@ -4,10 +4,10 @@
 import task::*;
 
 fn main() {
-    let other = task::spawn_joinable((), child);
+    let other = task::spawn_joinable {|| child(); };
     #error("1");
     yield();
     join(other);
 }
 
-fn child(&&_i: ()) { #error("2"); }
+fn child() { #error("2"); }
index 500189a0bc6f6818c239345036b6838b1afe0a86..7945aaed7447829b59487a465dd2c36b616e6117 100644 (file)
 #[ignore(cfg(target_os = "win32"))]
 fn test_unsupervise() {
     fn f() { task::unsupervise(); fail; }
-    task::spawn {|| f};
+    task::spawn {|| f();};
 }
 
 #[test]
 fn test_lib_spawn() {
     fn foo() { #error("Hello, World!"); }
-    task::spawn {|| foo};
+    task::spawn {|| foo();};
 }
 
 #[test]
@@ -54,6 +54,6 @@ fn test_join_chan_fail() {
 #[test]
 fn spawn_polymorphic() {
     fn foo<send T>(x: T) { log(error, x); }
-    task::spawn {|| foo(true);}
-    task::spawn {|| foo(42);}
+    task::spawn {|| foo(true);};
+    task::spawn {|| foo(42);};
 }
index 9994463ec3c9107ed2bb104900cd930565376cda..3bbea1db6be233bc4588a9f6c826efda8f692f03 100644 (file)
@@ -509,10 +509,10 @@ fn init() {
 fn init_empty() {
 
     let r = task::join(
-        task::spawn_joinable((), fn (&&_i: ()) {
+        task::spawn_joinable {||
             task::unsupervise();
             vec::init::<int>([]);
-        }));
+        });
     assert r == task::tr_failure
 }