Remove temporary fn# syntax
This commit is contained in:
parent
6fb9d4f83b
commit
ebc61e39d7
@ -2135,20 +2135,12 @@ fn parse_auth(p: parser) -> ast::_auth {
|
||||
} else { unexpected(p, p.peek()); }
|
||||
}
|
||||
|
||||
fn parse_fn_item_proto(p: parser) -> ast::proto {
|
||||
if p.peek() == token::POUND {
|
||||
p.bump();
|
||||
ast::proto_bare
|
||||
} else {
|
||||
ast::proto_bare
|
||||
}
|
||||
fn parse_fn_item_proto(_p: parser) -> ast::proto {
|
||||
ast::proto_bare
|
||||
}
|
||||
|
||||
fn parse_fn_ty_proto(p: parser) -> ast::proto {
|
||||
if p.peek() == token::POUND {
|
||||
p.bump();
|
||||
ast::proto_bare
|
||||
} else if p.peek() == token::AT {
|
||||
if p.peek() == token::AT {
|
||||
p.bump();
|
||||
ast::proto_shared(ast::sugar_normal)
|
||||
} else {
|
||||
@ -2157,10 +2149,7 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
|
||||
}
|
||||
|
||||
fn parse_fn_anon_proto(p: parser) -> ast::proto {
|
||||
if p.peek() == token::POUND {
|
||||
p.bump();
|
||||
ast::proto_bare
|
||||
} else if p.peek() == token::AT {
|
||||
if p.peek() == token::AT {
|
||||
p.bump();
|
||||
ast::proto_shared(ast::sugar_normal)
|
||||
} else {
|
||||
|
@ -195,7 +195,7 @@ fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn@()) ->
|
||||
(cx.config, cx.procsrv.chan, testfile), run_test_task);
|
||||
}
|
||||
|
||||
fn# run_test_task(args: (common::config, procsrv::reqchan, [u8])) {
|
||||
fn run_test_task(args: (common::config, procsrv::reqchan, [u8])) {
|
||||
|
||||
let (config, procsrv_chan, testfile) = args;
|
||||
|
||||
|
@ -39,7 +39,7 @@ fn mk() -> handle {
|
||||
let setupport = port();
|
||||
let task = task::spawn_joinable(
|
||||
chan(setupport),
|
||||
fn# (setupchan: chan<chan<request>>) {
|
||||
fn (setupchan: chan<chan<request>>) {
|
||||
let reqport = port();
|
||||
let reqchan = chan(reqport);
|
||||
send(setupchan, reqchan);
|
||||
|
@ -49,7 +49,7 @@ fn ip_to_sbuf(ip: net::ip_addr) -> *u8 unsafe {
|
||||
vec::to_ptr(str::bytes(net::format_addr(ip)))
|
||||
}
|
||||
|
||||
fn# connect_task(args: (net::ip_addr, int, chan<socket_event>)) {
|
||||
fn connect_task(args: (net::ip_addr, int, chan<socket_event>)) {
|
||||
let (ip, portnum, evt) = args;
|
||||
let connecter = port();
|
||||
rustrt::aio_connect(ip_to_sbuf(ip), portnum, chan(connecter));
|
||||
@ -84,7 +84,7 @@ fn new_client(client: client, evt: chan<socket_event>) {
|
||||
log "close message sent";
|
||||
}
|
||||
|
||||
fn# accept_task(args: (client, chan<server_event>)) {
|
||||
fn accept_task(args: (client, chan<server_event>)) {
|
||||
let (client, events) = args;
|
||||
log "accept task was spawned";
|
||||
let p = port();
|
||||
@ -94,7 +94,7 @@ fn# accept_task(args: (client, chan<server_event>)) {
|
||||
log "done accepting";
|
||||
}
|
||||
|
||||
fn# server_task(args: (net::ip_addr, int, chan<server_event>,
|
||||
fn server_task(args: (net::ip_addr, int, chan<server_event>,
|
||||
chan<server>)) {
|
||||
let (ip, portnum, events, server) = args;
|
||||
let accepter = port();
|
||||
@ -111,7 +111,7 @@ fn# server_task(args: (net::ip_addr, int, chan<server_event>,
|
||||
}
|
||||
}
|
||||
|
||||
fn# request_task(c: chan<ctx>) {
|
||||
fn request_task(c: chan<ctx>) {
|
||||
// Create a port to accept IO requests on
|
||||
let p = port();
|
||||
// Hand of its channel to our spawner
|
||||
@ -150,7 +150,7 @@ fn# request_task(c: chan<ctx>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn# iotask(c: chan<ctx>) {
|
||||
fn iotask(c: chan<ctx>) {
|
||||
log "io task spawned";
|
||||
// Initialize before accepting requests
|
||||
rustrt::aio_init();
|
||||
|
@ -93,16 +93,16 @@ fn unpin() { rustrt::unpin_task(); }
|
||||
|
||||
fn set_min_stack(stack_size: uint) { rustrt::set_min_stack(stack_size); }
|
||||
|
||||
fn spawn<~T>(-data: T, f: fn#(T)) -> task {
|
||||
fn spawn<~T>(-data: T, f: fn(T)) -> task {
|
||||
spawn_inner2(data, f, none)
|
||||
}
|
||||
|
||||
fn spawn_notify<~T>(-data: T, f: fn#(T),
|
||||
fn spawn_notify<~T>(-data: T, f: fn(T),
|
||||
notify: comm::chan<task_notification>) -> task {
|
||||
spawn_inner2(data, f, some(notify))
|
||||
}
|
||||
|
||||
fn spawn_joinable<~T>(-data: T, f: fn#(T)) -> joinable_task {
|
||||
fn spawn_joinable<~T>(-data: T, f: fn(T)) -> joinable_task {
|
||||
let p = comm::port::<task_notification>();
|
||||
let id = spawn_notify(data, f, comm::chan::<task_notification>(p));
|
||||
ret (id, p);
|
||||
@ -118,11 +118,11 @@ fn spawn_joinable<~T>(-data: T, f: fn#(T)) -> joinable_task {
|
||||
//
|
||||
// After the transition this should all be rewritten.
|
||||
|
||||
fn spawn_inner2<~T>(-data: T, f: fn#(T),
|
||||
fn spawn_inner2<~T>(-data: T, f: fn(T),
|
||||
notify: option<comm::chan<task_notification>>)
|
||||
-> task_id {
|
||||
|
||||
fn wrapper<~T>(-data: *u8, f: fn#(T)) {
|
||||
fn wrapper<~T>(-data: *u8, f: fn(T)) {
|
||||
let data: ~T = unsafe::reinterpret_cast(data);
|
||||
f(*data);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ type test_name = str;
|
||||
// to support isolation of tests into tasks.
|
||||
type test_fn<@T> = T;
|
||||
|
||||
type default_test_fn = test_fn<fn#()>;
|
||||
type default_test_fn = test_fn<fn()>;
|
||||
|
||||
// The definition of a single test. A test runner will run a list of
|
||||
// these.
|
||||
@ -321,7 +321,7 @@ fn run_test<@T>(test: test_desc<T>,
|
||||
// We need to run our tests in another task in order to trap test failures.
|
||||
// This function only works with functions that don't contain closures.
|
||||
fn default_test_to_task(&&f: default_test_fn) -> joinable {
|
||||
fn# run_task(f: default_test_fn) {
|
||||
fn run_task(f: default_test_fn) {
|
||||
configure_test_task();
|
||||
f();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import std::comm::send;
|
||||
import std::comm::recv;
|
||||
|
||||
fn fib(n: int) -> int {
|
||||
fn# pfib(args: (chan<int>, int)) {
|
||||
fn pfib(args: (chan<int>, int)) {
|
||||
let (c, n) = args;
|
||||
if n == 0 {
|
||||
send(c, 0);
|
||||
@ -62,7 +62,7 @@ fn parse_opts(argv: [str]) -> config {
|
||||
}
|
||||
}
|
||||
|
||||
fn# stress_task(&&id: int) {
|
||||
fn stress_task(&&id: int) {
|
||||
let i = 0;
|
||||
while true {
|
||||
let n = 15;
|
||||
|
@ -4,7 +4,7 @@ import std::task;
|
||||
import std::uint;
|
||||
import std::str;
|
||||
|
||||
fn# f(&&n: uint) {
|
||||
fn f(&&n: uint) {
|
||||
let i = 0u;
|
||||
while i < n {
|
||||
task::join(task::spawn_joinable((), g));
|
||||
@ -12,7 +12,7 @@ fn# f(&&n: uint) {
|
||||
}
|
||||
}
|
||||
|
||||
fn# g(&&_i: ()) { }
|
||||
fn g(&&_i: ()) { }
|
||||
|
||||
fn main(args: [str]) {
|
||||
let n =
|
||||
|
@ -9,7 +9,7 @@ import std::uint;
|
||||
import std::str;
|
||||
import std::task;
|
||||
|
||||
fn# f(&&n: uint) {
|
||||
fn f(&&n: uint) {
|
||||
for each i in uint::range(0u, n) {
|
||||
let v: [u8] = [];
|
||||
vec::reserve(v, 1000u);
|
||||
|
@ -75,7 +75,7 @@ mod map_reduce {
|
||||
ret tasks;
|
||||
}
|
||||
|
||||
fn# map_task(args: (chan<ctrl_proto>, str)) {
|
||||
fn map_task(args: (chan<ctrl_proto>, str)) {
|
||||
let (ctrl, input) = args;
|
||||
// log_err "map_task " + input;
|
||||
let intermediates = map::new_str_hash();
|
||||
@ -108,7 +108,7 @@ mod map_reduce {
|
||||
send(ctrl, mapper_done);
|
||||
}
|
||||
|
||||
fn# reduce_task(args: (str, chan<chan<reduce_proto>>)) {
|
||||
fn reduce_task(args: (str, chan<chan<reduce_proto>>)) {
|
||||
let (key, out) = args;
|
||||
let p = port();
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
// error-pattern:mismatched types: expected fn() but found fn@()
|
||||
|
||||
fn# f() {
|
||||
fn f() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Can't produce a bare function by binding
|
||||
let g: fn#() = bind f();
|
||||
let g: fn() = bind f();
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
// Issue #1038
|
||||
|
||||
fn main() {
|
||||
fn# foo<T>() { }
|
||||
fn foo<T>() { }
|
||||
|
||||
// This wants to build a closure over type int,
|
||||
// but there's no way to do that while still being a bare function
|
||||
let f: fn#() = foo::<int>;
|
||||
let f: fn() = foo::<int>;
|
||||
}
|
@ -2,12 +2,12 @@
|
||||
// Issue #1038
|
||||
|
||||
fn main() {
|
||||
fn# foo<T>(i: T) { }
|
||||
fn foo<T>(i: T) { }
|
||||
|
||||
// This wants to build a closure over type int,
|
||||
// but there's no way to do that while still being a bare function
|
||||
f(foo);
|
||||
}
|
||||
|
||||
fn f(i: fn#(&&int)) {
|
||||
fn f(i: fn(&&int)) {
|
||||
}
|
@ -3,6 +3,6 @@
|
||||
use std;
|
||||
import std::task;
|
||||
|
||||
fn# f(&&x: int) -> int { ret x; }
|
||||
fn f(&&x: int) -> int { ret x; }
|
||||
|
||||
fn main() { task::spawn(10, f); }
|
||||
|
@ -6,7 +6,7 @@ import std::task;
|
||||
import std::comm::port;
|
||||
import std::comm::recv;
|
||||
|
||||
fn# child(&&_i: ()) { assert (1 == 2); }
|
||||
fn child(&&_i: ()) { assert (1 == 2); }
|
||||
|
||||
fn main() {
|
||||
let p = port::<int>();
|
||||
|
@ -7,7 +7,7 @@ import std::comm::chan;
|
||||
import std::comm::port;
|
||||
import std::comm::recv;
|
||||
|
||||
fn# child(&&_i: ()) { fail; }
|
||||
fn child(&&_i: ()) { fail; }
|
||||
|
||||
fn main() {
|
||||
let p = port::<int>();
|
||||
|
@ -6,9 +6,9 @@ import std::task;
|
||||
import std::comm::port;
|
||||
import std::comm::recv;
|
||||
|
||||
fn# grandchild(&&_i: ()) { fail; }
|
||||
fn grandchild(&&_i: ()) { fail; }
|
||||
|
||||
fn# child(&&_i: ()) {
|
||||
fn child(&&_i: ()) {
|
||||
let p = port::<int>();
|
||||
task::spawn((), grandchild);
|
||||
let x = recv(p);
|
||||
|
@ -4,7 +4,7 @@ use std;
|
||||
import std::task;
|
||||
import std::comm;
|
||||
|
||||
fn# goodfail(&&_i: ()) {
|
||||
fn goodfail(&&_i: ()) {
|
||||
task::yield();
|
||||
fail "goodfail";
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import std::comm::send;
|
||||
import std::comm::recv;
|
||||
import std::task;
|
||||
|
||||
fn# a(c: chan<int>) { send(c, 10); }
|
||||
fn a(c: chan<int>) { send(c, 10); }
|
||||
|
||||
fn main() {
|
||||
let p = port();
|
||||
|
@ -7,7 +7,7 @@ import std::comm::chan;
|
||||
import std::comm::recv;
|
||||
import std::task;
|
||||
|
||||
fn# a(c: chan<int>) { log "task a0"; log "task a1"; send(c, 10); }
|
||||
fn a(c: chan<int>) { log "task a0"; log "task a1"; send(c, 10); }
|
||||
|
||||
fn main() {
|
||||
let p = comm::port();
|
||||
@ -19,7 +19,7 @@ fn main() {
|
||||
log "Finished.";
|
||||
}
|
||||
|
||||
fn# b(c: chan<int>) {
|
||||
fn b(c: chan<int>) {
|
||||
log "task b0";
|
||||
log "task b1";
|
||||
log "task b2";
|
||||
|
@ -7,7 +7,7 @@ import std::comm::chan;
|
||||
import std::comm::recv;
|
||||
import std::task;
|
||||
|
||||
fn# a(c: chan<int>) {
|
||||
fn a(c: chan<int>) {
|
||||
if true {
|
||||
log "task a";
|
||||
log "task a";
|
||||
@ -37,7 +37,7 @@ fn main() {
|
||||
log "children finished, root finishing";
|
||||
}
|
||||
|
||||
fn# b(c: chan<int>) {
|
||||
fn b(c: chan<int>) {
|
||||
if true {
|
||||
log "task b";
|
||||
log "task b";
|
||||
|
@ -87,7 +87,7 @@ fn test_ptr() {
|
||||
}
|
||||
|
||||
fn test_task() {
|
||||
fn# f(&&_i: ()) { }
|
||||
fn f(&&_i: ()) { }
|
||||
let f1 = f, f2 = f;
|
||||
let t1 = task::spawn((), f1);
|
||||
let t2 = task::spawn((), f2);
|
||||
|
@ -12,7 +12,7 @@ tag request { quit; close(chan<bool>); }
|
||||
|
||||
type ctx = chan<request>;
|
||||
|
||||
fn# request_task(c: chan<ctx>) {
|
||||
fn request_task(c: chan<ctx>) {
|
||||
let p = port();
|
||||
send(c, chan(p));
|
||||
let req: request;
|
||||
|
@ -3,6 +3,6 @@
|
||||
use std;
|
||||
import std::task;
|
||||
|
||||
fn# child2(&&s: str) { }
|
||||
fn child2(&&s: str) { }
|
||||
|
||||
fn main() { let x = task::spawn("hi", child2); }
|
||||
|
@ -16,7 +16,7 @@ fn main() {
|
||||
assert (y == 10);
|
||||
}
|
||||
|
||||
fn# child(c: chan<int>) {
|
||||
fn child(c: chan<int>) {
|
||||
log_err "sending";
|
||||
send(c, 10);
|
||||
log_err "value sent"
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
let f: fn#() = fn# () {
|
||||
let f: fn() = fn () {
|
||||
log "This is a bare function"
|
||||
};
|
||||
let g;
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
let f: fn#() = fn# () {
|
||||
let f: fn() = fn () {
|
||||
log "This is a bare function"
|
||||
};
|
||||
f();
|
||||
|
@ -1,9 +1,9 @@
|
||||
fn# f(i: int, &called: bool) {
|
||||
fn f(i: int, &called: bool) {
|
||||
assert i == 10;
|
||||
called = true;
|
||||
}
|
||||
|
||||
fn# g(f: fn#(int, &bool), &called: bool) {
|
||||
fn g(f: fn(int, &bool), &called: bool) {
|
||||
f(10, called);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn# f<T>(i: T, j: T, k: T) {
|
||||
fn f<T>(i: T, j: T, k: T) {
|
||||
assert i == j;
|
||||
assert j != k;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn# f(i: int) {
|
||||
fn f(i: int) {
|
||||
assert i == 10;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn# bare() {}
|
||||
fn bare() {}
|
||||
|
||||
fn likes_block(f: block()) { f() }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn# bare() {}
|
||||
fn bare() {}
|
||||
|
||||
fn likes_shared(f: fn@()) { f() }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn# f() {
|
||||
fn f() {
|
||||
log "This is a bare function";
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,6 @@ use std;
|
||||
|
||||
fn main() {
|
||||
// Bare functions should just be a pointer
|
||||
assert std::sys::rustrt::size_of::<fn#()>() ==
|
||||
assert std::sys::rustrt::size_of::<fn()>() ==
|
||||
std::sys::rustrt::size_of::<int>();
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
// This is what the signature to spawn should look like with bare functions
|
||||
|
||||
fn spawn<~T>(val: T, f: fn#(T)) {
|
||||
fn spawn<~T>(val: T, f: fn(T)) {
|
||||
f(val);
|
||||
}
|
||||
|
||||
fn# f(&&i: int) {
|
||||
fn f(&&i: int) {
|
||||
assert i == 100;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
spawn(100, f);
|
||||
spawn(100, fn#(&&i: int) {
|
||||
spawn(100, fn(&&i: int) {
|
||||
assert i == 100;
|
||||
});
|
||||
}
|
@ -3,5 +3,5 @@ type r = {
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let i: r = {field: fn#() { }};
|
||||
let i: r = {field: fn() { }};
|
||||
}
|
@ -36,7 +36,7 @@ mod map_reduce {
|
||||
for i: str in inputs { task::spawn((ctrl, i), map_task); }
|
||||
}
|
||||
|
||||
fn# map_task(&&args: (chan<ctrl_proto>, str)) {
|
||||
fn map_task(&&args: (chan<ctrl_proto>, str)) {
|
||||
let (ctrl, input) = args;
|
||||
|
||||
let intermediates = map::new_str_hash();
|
||||
|
@ -9,6 +9,6 @@ native "rust" mod rustrt {
|
||||
fn task_yield();
|
||||
}
|
||||
|
||||
fn# yield_wrap(&&_i: ()) unsafe { rustrt::task_yield(); }
|
||||
fn yield_wrap(&&_i: ()) unsafe { rustrt::task_yield(); }
|
||||
|
||||
fn main() { task::spawn((), yield_wrap); }
|
||||
|
@ -15,9 +15,9 @@ import std::comm::send;
|
||||
import std::comm::port;
|
||||
import std::comm::recv;
|
||||
|
||||
fn# grandchild(c: chan<int>) { send(c, 42); }
|
||||
fn grandchild(c: chan<int>) { send(c, 42); }
|
||||
|
||||
fn# child(c: chan<int>) {
|
||||
fn child(c: chan<int>) {
|
||||
let _grandchild = task::spawn_joinable(c, grandchild);
|
||||
join(_grandchild);
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import std::comm::send;
|
||||
|
||||
tag msg { closed; received([u8]); }
|
||||
|
||||
fn# producer(c: chan<[u8]>) {
|
||||
fn producer(c: chan<[u8]>) {
|
||||
send(c, [1u8, 2u8, 3u8, 4u8]);
|
||||
let empty: [u8] = [];
|
||||
send(c, empty);
|
||||
}
|
||||
|
||||
fn# packager(&&args: (chan<chan<[u8]>>, chan<msg>)) {
|
||||
fn packager(&&args: (chan<chan<[u8]>>, chan<msg>)) {
|
||||
let (cb, msg) = args;
|
||||
let p: port<[u8]> = port();
|
||||
send(cb, chan(p));
|
||||
|
@ -7,7 +7,7 @@ import std::comm::port;
|
||||
import std::comm::send;
|
||||
import std::comm::recv;
|
||||
|
||||
fn# producer(c: chan<[u8]>) {
|
||||
fn producer(c: chan<[u8]>) {
|
||||
send(c,
|
||||
[1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8,
|
||||
13u8]);
|
||||
|
@ -12,4 +12,4 @@ fn main() {
|
||||
log_err "3";
|
||||
}
|
||||
|
||||
fn# child(&&_i: ()) { log_err "2"; }
|
||||
fn child(&&_i: ()) { log_err "2"; }
|
||||
|
@ -21,4 +21,4 @@ fn main() {
|
||||
assert (y == 10);
|
||||
}
|
||||
|
||||
fn# child(c: chan<int>) { send(c, 10); }
|
||||
fn child(c: chan<int>) { send(c, 10); }
|
||||
|
@ -5,9 +5,9 @@ import std::task;
|
||||
import std::comm::port;
|
||||
import std::comm::recv;
|
||||
|
||||
fn# child(&&_i: ()) { assert (1 == 2); }
|
||||
fn child(&&_i: ()) { assert (1 == 2); }
|
||||
|
||||
fn# parent(&&_i: ()) {
|
||||
fn parent(&&_i: ()) {
|
||||
// Since this task isn't supervised it won't bring down the whole
|
||||
// process
|
||||
task::unsupervise();
|
||||
|
@ -4,11 +4,11 @@ import std::task;
|
||||
import std::comm;
|
||||
import std::uint;
|
||||
|
||||
fn# die(&&_i: ()) {
|
||||
fn die(&&_i: ()) {
|
||||
fail;
|
||||
}
|
||||
|
||||
fn# iloop(&&_i: ()) {
|
||||
fn iloop(&&_i: ()) {
|
||||
task::unsupervise();
|
||||
task::spawn((), die);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use std;
|
||||
import std::task;
|
||||
import std::comm;
|
||||
|
||||
fn# sub(&&args: (comm::chan<int>, int)) {
|
||||
fn sub(&&args: (comm::chan<int>, int)) {
|
||||
let (parent, id) = args;
|
||||
if id == 0 {
|
||||
comm::send(parent, 0);
|
||||
|
@ -4,11 +4,11 @@ import std::task;
|
||||
import std::comm;
|
||||
import std::uint;
|
||||
|
||||
fn# die(&&_i: ()) {
|
||||
fn die(&&_i: ()) {
|
||||
fail;
|
||||
}
|
||||
|
||||
fn# iloop(&&_i: ()) {
|
||||
fn iloop(&&_i: ()) {
|
||||
task::unsupervise();
|
||||
task::spawn((), die);
|
||||
let p = comm::port::<()>();
|
||||
|
@ -4,7 +4,7 @@ use std;
|
||||
import std::task::yield;
|
||||
import std::task;
|
||||
|
||||
fn# x(&&args: (str, int)) {
|
||||
fn x(&&args: (str, int)) {
|
||||
let (s, n) = args;
|
||||
log s; log n;
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ import std::task::spawn_joinable;
|
||||
fn main() { let x = spawn_joinable(10, m::child); join(x); }
|
||||
|
||||
mod m {
|
||||
fn# child(&&i: int) { log i; }
|
||||
fn child(&&i: int) { log i; }
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import std::task;
|
||||
|
||||
type ctx = comm::chan<int>;
|
||||
|
||||
fn# iotask(&&args: (ctx, str)) {
|
||||
fn iotask(&&args: (ctx, str)) {
|
||||
let (cx, ip) = args;
|
||||
assert (str::eq(ip, "localhost"));
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import std::task;
|
||||
|
||||
fn main() { let t = task::spawn_joinable(10, child); task::join(t); }
|
||||
|
||||
fn# child(&&i: int) { log_err i; assert (i == 10); }
|
||||
fn child(&&i: int) { log_err i; assert (i == 10); }
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
|
@ -5,7 +5,7 @@ import std::task::spawn;
|
||||
|
||||
fn main() { spawn((10, 20, 30, 40, 50, 60, 70, 80, 90), child); }
|
||||
|
||||
fn# child(&&args: (int, int, int, int, int, int, int, int, int)) {
|
||||
fn child(&&args: (int, int, int, int, int, int, int, int, int)) {
|
||||
let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
|
||||
log_err i1;
|
||||
log_err i2;
|
||||
|
@ -7,7 +7,7 @@ import std::task;
|
||||
|
||||
fn main() { test05(); }
|
||||
|
||||
fn# test05_start(ch : chan<int>) {
|
||||
fn test05_start(ch : chan<int>) {
|
||||
log_err ch;
|
||||
send(ch, 10);
|
||||
log_err "sent 10";
|
||||
|
@ -5,7 +5,7 @@ import std::task::join;
|
||||
|
||||
fn main() { test00(); }
|
||||
|
||||
fn# start(&&_i: ()) { log "Started / Finished task."; }
|
||||
fn start(&&_i: ()) { log "Started / Finished task."; }
|
||||
|
||||
fn test00() {
|
||||
let t = spawn_joinable((), start);
|
||||
|
@ -2,7 +2,7 @@ use std;
|
||||
import std::task;
|
||||
import std::comm;
|
||||
|
||||
fn# start(c: comm::chan<comm::chan<str>>) {
|
||||
fn start(c: comm::chan<comm::chan<str>>) {
|
||||
let p = comm::port();
|
||||
comm::send(c, comm::chan(p));
|
||||
|
||||
|
@ -2,7 +2,7 @@ use std;
|
||||
import std::comm;
|
||||
import std::task;
|
||||
|
||||
fn# start(c: comm::chan<comm::chan<int>>) {
|
||||
fn start(c: comm::chan<comm::chan<int>>) {
|
||||
let p: comm::port<int> = comm::port();
|
||||
comm::send(c, comm::chan(p));
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import std::task;
|
||||
|
||||
fn main() { test00(); }
|
||||
|
||||
fn# start(&&task_number: int) { log "Started / Finished task."; }
|
||||
fn start(&&task_number: int) { log "Started / Finished task."; }
|
||||
|
||||
fn test00() {
|
||||
let i: int = 0;
|
||||
|
@ -3,7 +3,7 @@ import std::task;
|
||||
import std::comm;
|
||||
import std::comm::send;
|
||||
|
||||
fn# start(&&args: (comm::chan<int>, int, int)) {
|
||||
fn start(&&args: (comm::chan<int>, int, int)) {
|
||||
let (c, start, number_of_messages) = args;
|
||||
let i: int = 0;
|
||||
while i < number_of_messages { send(c, start + i); i += 1; }
|
||||
|
@ -27,7 +27,7 @@ fn main() {
|
||||
log "main thread exiting";
|
||||
}
|
||||
|
||||
fn# child(&&args: (int, comm::chan<int>)) {
|
||||
fn child(&&args: (int, comm::chan<int>)) {
|
||||
let (x, ch) = args;
|
||||
log x;
|
||||
comm::send(ch, x);
|
||||
|
@ -5,7 +5,7 @@ import std::task;
|
||||
|
||||
fn main() { log "===== SPAWNING and JOINING THREAD TASKS ====="; test00(); }
|
||||
|
||||
fn# start(&&task_number: int) {
|
||||
fn start(&&task_number: int) {
|
||||
log "Started task.";
|
||||
let i: int = 0;
|
||||
while i < 10000 { i = i + 1; }
|
||||
|
@ -7,7 +7,7 @@ import std::comm::recv;
|
||||
|
||||
fn main() { log "===== WITHOUT THREADS ====="; test00(); }
|
||||
|
||||
fn# test00_start(&&args: (chan<int>, int, int)) {
|
||||
fn test00_start(&&args: (chan<int>, int, int)) {
|
||||
let (ch, message, count) = args;
|
||||
log "Starting test00_start";
|
||||
let i: int = 0;
|
||||
|
@ -7,7 +7,7 @@ import comm::port;
|
||||
|
||||
fn main() { test00(); }
|
||||
|
||||
fn# test00_start(&&args: (comm::chan<int>, int, int)) {
|
||||
fn test00_start(&&args: (comm::chan<int>, int, int)) {
|
||||
let (c, start, number_of_messages) = args;
|
||||
let i: int = 0;
|
||||
while i < number_of_messages { comm::send(c, start + i); i += 1; }
|
||||
|
@ -4,7 +4,7 @@ import std::comm;
|
||||
|
||||
fn main() { test00(); }
|
||||
|
||||
fn# test00_start(&&args: (comm::chan<int>, int, int)) {
|
||||
fn test00_start(&&args: (comm::chan<int>, int, int)) {
|
||||
let (c, start, number_of_messages) = args;
|
||||
let i: int = 0;
|
||||
while i < number_of_messages { comm::send(c, start + i); i += 1; }
|
||||
|
@ -4,7 +4,7 @@ import std::comm;
|
||||
|
||||
fn main() { test00(); }
|
||||
|
||||
fn# test00_start(&&args: (comm::chan<int>, int)) {
|
||||
fn test00_start(&&args: (comm::chan<int>, int)) {
|
||||
let (c, number_of_messages) = args;
|
||||
let i: int = 0;
|
||||
while i < number_of_messages { comm::send(c, i + 0); i += 1; }
|
||||
|
@ -2,6 +2,6 @@ use std;
|
||||
import std::task;
|
||||
fn main() { task::spawn("Hello", child); }
|
||||
|
||||
fn# child(&&s: str) {
|
||||
fn child(&&s: str) {
|
||||
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ fn test_cont() { let i = 0; while i < 1 { i += 1; let x: @int = cont; } }
|
||||
fn test_ret() { let x: @int = ret; }
|
||||
|
||||
fn test_fail() {
|
||||
fn# f(&&_i: ()) { std::task::unsupervise(); let x: @int = fail; }
|
||||
fn f(&&_i: ()) { std::task::unsupervise(); let x: @int = fail; }
|
||||
std::task::spawn((), f);
|
||||
}
|
||||
|
||||
fn test_fail_indirect() {
|
||||
fn f() -> ! { fail; }
|
||||
fn# g(&&_i: ()) { std::task::unsupervise(); let x: @int = f(); }
|
||||
fn g(&&_i: ()) { std::task::unsupervise(); let x: @int = f(); }
|
||||
std::task::spawn((), g);
|
||||
}
|
||||
|
||||
|
@ -9,5 +9,5 @@ fn main() {
|
||||
log "main thread exiting";
|
||||
}
|
||||
|
||||
fn# child(&&x: int) { log x; }
|
||||
fn child(&&x: int) { log x; }
|
||||
|
||||
|
@ -3,7 +3,7 @@ import std::comm;
|
||||
import std::task;
|
||||
import std::uint;
|
||||
|
||||
fn# child(args: (comm::chan<~uint>, uint)) {
|
||||
fn child(args: (comm::chan<~uint>, uint)) {
|
||||
let (c, i) = args;
|
||||
comm::send(c, ~i);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
use std;
|
||||
import std::task;
|
||||
|
||||
fn# f(&&_i: ()) {
|
||||
fn f(&&_i: ()) {
|
||||
task::unsupervise();
|
||||
let a = @0;
|
||||
fail;
|
||||
|
@ -7,7 +7,7 @@ resource complainer(c: comm::chan<bool>) {
|
||||
comm::send(c, true);
|
||||
}
|
||||
|
||||
fn# f(c: comm::chan<bool>) {
|
||||
fn f(c: comm::chan<bool>) {
|
||||
task::unsupervise();
|
||||
let c <- complainer(c);
|
||||
fail;
|
||||
|
@ -6,7 +6,7 @@ import std::comm;
|
||||
resource complainer(c: @int) {
|
||||
}
|
||||
|
||||
fn# f(&&_i: ()) {
|
||||
fn f(&&_i: ()) {
|
||||
task::unsupervise();
|
||||
let c <- complainer(@0);
|
||||
fail;
|
||||
|
@ -2,7 +2,7 @@
|
||||
use std;
|
||||
import std::task;
|
||||
|
||||
fn# f(&&_i: ()) {
|
||||
fn f(&&_i: ()) {
|
||||
task::unsupervise();
|
||||
let a = ~0;
|
||||
fail;
|
||||
|
@ -13,6 +13,6 @@ fn main() {
|
||||
join(other);
|
||||
}
|
||||
|
||||
fn# child(&&_i: ()) {
|
||||
fn child(&&_i: ()) {
|
||||
log_err "4"; yield(); log_err "5"; yield(); log_err "6";
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ fn main() {
|
||||
join(other);
|
||||
}
|
||||
|
||||
fn# child(&&_i: ()) { log_err "2"; }
|
||||
fn child(&&_i: ()) { log_err "2"; }
|
||||
|
@ -15,25 +15,25 @@ fn test_unsupervise() { }
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_unsupervise() {
|
||||
fn# f(&&_i: ()) { task::unsupervise(); fail; }
|
||||
fn f(&&_i: ()) { task::unsupervise(); fail; }
|
||||
task::spawn((), f);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lib_spawn() {
|
||||
fn# foo(&&_i: ()) { log_err "Hello, World!"; }
|
||||
fn foo(&&_i: ()) { log_err "Hello, World!"; }
|
||||
task::spawn((), foo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lib_spawn2() {
|
||||
fn# foo(&&x: int) { assert (x == 42); }
|
||||
fn foo(&&x: int) { assert (x == 42); }
|
||||
task::spawn(42, foo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_join_chan() {
|
||||
fn# winner(&&_i: ()) { }
|
||||
fn winner(&&_i: ()) { }
|
||||
|
||||
let p = comm::port();
|
||||
task::spawn_notify((), winner, comm::chan(p));
|
||||
@ -56,7 +56,7 @@ fn test_join_chan_fail() { }
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_join_chan_fail() {
|
||||
fn# failer(&&_i: ()) { task::unsupervise(); fail }
|
||||
fn failer(&&_i: ()) { task::unsupervise(); fail }
|
||||
|
||||
let p = comm::port();
|
||||
task::spawn_notify((), failer, comm::chan(p));
|
||||
@ -71,7 +71,7 @@ fn test_join_chan_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_join_convenient() {
|
||||
fn# winner(&&_i: ()) { }
|
||||
fn winner(&&_i: ()) { }
|
||||
let handle = task::spawn_joinable((), winner);
|
||||
assert (task::tr_success == task::join(handle));
|
||||
}
|
||||
@ -80,7 +80,7 @@ fn test_join_convenient() {
|
||||
#[ignore]
|
||||
fn spawn_polymorphic() {
|
||||
// FIXME #1038: Can't spawn palymorphic functions
|
||||
/*fn# foo<~T>(x: T) { log_err x; }
|
||||
/*fn foo<~T>(x: T) { log_err x; }
|
||||
|
||||
task::spawn(true, foo);
|
||||
task::spawn(42, foo);*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user