2011-12-15 20:44:13 -06:00
|
|
|
use std;
|
|
|
|
|
|
|
|
import std::comm;
|
|
|
|
import std::comm::chan;
|
|
|
|
import std::comm::send;
|
|
|
|
|
|
|
|
fn main() { test05(); }
|
|
|
|
|
|
|
|
type pair<A,B> = { a: A, b: B };
|
|
|
|
|
2012-01-05 08:35:37 -06:00
|
|
|
fn make_generic_record<A: copy, B: copy>(a: A, b: B) -> pair<A,B> {
|
2011-12-15 20:44:13 -06:00
|
|
|
ret {a: a, b: b};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test05_start(&&f: sendfn(&&float, &&str) -> pair<float, str>) {
|
|
|
|
let p = f(22.22f, "Hi");
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, p);
|
2011-12-15 20:44:13 -06:00
|
|
|
assert p.a == 22.22f;
|
|
|
|
assert p.b == "Hi";
|
|
|
|
|
|
|
|
let q = f(44.44f, "Ho");
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, q);
|
2011-12-15 20:44:13 -06:00
|
|
|
assert q.a == 44.44f;
|
|
|
|
assert q.b == "Ho";
|
|
|
|
}
|
|
|
|
|
2012-01-05 08:35:37 -06:00
|
|
|
fn spawn<A: copy, B: copy>(f: fn(sendfn(A,B)->pair<A,B>)) {
|
2011-12-15 20:44:13 -06:00
|
|
|
let arg = sendfn(a: A, b: B) -> pair<A,B> {
|
|
|
|
ret make_generic_record(a, b);
|
|
|
|
};
|
|
|
|
task::spawn(arg, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test05() {
|
|
|
|
spawn::<float,str>(test05_start);
|
|
|
|
}
|