De-mode comm::Chan

This commit is contained in:
Tim Chevalier 2012-10-03 14:38:01 -07:00
parent 777baeb298
commit fe12da0864
63 changed files with 173 additions and 173 deletions

View file

@ -10,7 +10,7 @@ fn a(c: Chan<int>) { send(c, 10); }
fn main() {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
task::spawn(|| a(ch) );
task::spawn(|| a(ch) );
let mut n: int = 0;

View file

@ -10,7 +10,7 @@ fn a(c: Chan<int>) { debug!("task a0"); debug!("task a1"); send(c, 10); }
fn main() {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
task::spawn(|| a(ch) );
task::spawn(|| b(ch) );
let mut n: int = 0;

View file

@ -29,7 +29,7 @@ fn main() {
let mut n: int = 2 + 3 * 7;
let s: ~str = ~"hello there";
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
task::spawn(|| a(ch) );
task::spawn(|| b(ch) );
let mut x: int = 10;

View file

@ -17,7 +17,7 @@ use comm::*;
fn foo(&&x: ()) -> Port<()> {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do task::spawn() |copy c, copy x| {
c.send(x);
}

View file

@ -12,7 +12,7 @@ type ctx = Chan<request>;
fn request_task(c: Chan<ctx>) {
let p = Port();
send(c, Chan(p));
send(c, Chan(&p));
let mut req: request;
req = recv(p);
// Need to drop req before receiving it again
@ -21,7 +21,7 @@ fn request_task(c: Chan<ctx>) {
fn new_cx() -> ctx {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
let t = task::spawn(|| request_task(ch) );
let mut cx: ctx;
cx = recv(p);
@ -32,6 +32,6 @@ fn main() {
let cx = new_cx();
let p = Port::<bool>();
send(cx, close(Chan(p)));
send(cx, close(Chan(&p)));
send(cx, quit);
}

View file

@ -7,7 +7,7 @@ use comm::recv;
fn main() {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let t = task::spawn(|| child(ch) );
let y = recv(p);
error!("received");

View file

@ -8,7 +8,7 @@ use comm::recv;
fn main() {
let po = Port();
let ch = Chan(po);
let ch = Chan(&po);
send(ch, 10);
let i = recv(po);
assert (i == 10);

View file

@ -47,7 +47,7 @@ mod map_reduce {
None => {
let p = Port();
error!("sending find_reducer");
send(ctrl, find_reducer(str::to_bytes(key), Chan(p)));
send(ctrl, find_reducer(str::to_bytes(key), Chan(&p)));
error!("receiving");
c = recv(p);
log(error, c);
@ -70,7 +70,7 @@ mod map_reduce {
reducers = map::HashMap();
start_mappers(Chan(ctrl), inputs);
start_mappers(Chan(&ctrl), inputs);
let mut num_mappers = vec::len(inputs) as int;

View file

@ -20,7 +20,7 @@ fn child(c: Chan<int>) {
fn main() {
let p = comm::Port();
let ch = Chan(p);
let ch = Chan(&p);
task::spawn(|| child(ch) );

View file

@ -14,7 +14,7 @@ fn producer(c: Chan<~[u8]>) {
fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
let p: Port<~[u8]> = Port();
send(cb, Chan(p));
send(cb, Chan(&p));
loop {
debug!("waiting for bytes");
let data = recv(p);
@ -35,9 +35,9 @@ fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
fn main() {
let p: Port<msg> = Port();
let ch = Chan(p);
let ch = Chan(&p);
let recv_reader: Port<Chan<~[u8]>> = Port();
let recv_reader_chan = Chan(recv_reader);
let recv_reader_chan = Chan(&recv_reader);
let pack = task::spawn(|| packager(recv_reader_chan, ch) );
let source_chan: Chan<~[u8]> = recv(recv_reader);

View file

@ -6,10 +6,10 @@ fn a() {
fn doit() {
fn b(c: Chan<Chan<int>>) {
let p = Port();
send(c, Chan(p));
send(c, Chan(&p));
}
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
spawn(|| b(ch) );
recv(p);
}

View file

@ -13,7 +13,7 @@ fn producer(c: Chan<~[u8]>) {
fn main() {
let p: Port<~[u8]> = Port();
let ch = Chan(p);
let ch = Chan(&p);
let prod = task::spawn(|| producer(ch) );
let data: ~[u8] = recv(p);

View file

@ -5,7 +5,7 @@ use comm::*;
fn main() {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
let mut y: int;
task::spawn(|| child(ch) );

View file

@ -7,7 +7,7 @@ fn sub(parent: comm::Chan<int>, id: int) {
comm::send(parent, 0);
} else {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let child = task::spawn(|| sub(ch, id - 1) );
let y = comm::recv(p);
comm::send(parent, y + 1);
@ -16,7 +16,7 @@ fn sub(parent: comm::Chan<int>, id: int) {
fn main() {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let child = task::spawn(|| sub(ch, 200) );
let y = comm::recv(p);
debug!("transmission complete");

View file

@ -18,7 +18,7 @@ type record = {val1: u32, val2: u32, val3: u32};
// assertions.
fn test_init() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
}
@ -28,7 +28,7 @@ fn test_init() {
// Don't trigger any assertions.
fn test_grow() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 100u) |i| {
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
comm::send(mychan, val);
@ -39,14 +39,14 @@ fn test_grow() {
// Don't allow the buffer to shrink below it's original size
fn test_shrink1() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
send(mychan, 0i8);
let x = recv(myport);
}
fn test_shrink2() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 100u) |_i| {
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
@ -58,7 +58,7 @@ fn test_shrink2() {
// Test rotating the buffer when the unit size is not a power of two
fn test_rotate() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 100u) |i| {
let val = {val1: i as u32, val2: i as u32, val3: i as u32};
send(mychan, val);
@ -74,7 +74,7 @@ fn test_rotate() {
// the unit size is not a power of two
fn test_rotate_grow() {
let myport = Port::<record>();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 10u) |j| {
for uint::range(0u, 10u) |i| {
let val: record =

View file

@ -18,7 +18,7 @@ extern mod rustrt {
fn main() unsafe {
let po = comm::Port();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
let parent_sched_id = rustrt::rust_get_sched_id();
error!("parent %?", parent_sched_id);
let num_threads = 1u;

View file

@ -8,7 +8,7 @@ fn die() {
fn iloop() {
task::spawn(|| die() );
let p = comm::Port::<()>();
let c = comm::Chan(p);
let c = comm::Chan(&p);
loop {
// Sending and receiving here because these actions yield,
// at which point our child can kill us

View file

@ -14,11 +14,11 @@ fn test(f: int) -> test {
fn main() {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do spawn() {
let p = Port();
c.send(Chan(p));
c.send(Chan(&p));
let _r = p.recv();
}

View file

@ -8,6 +8,6 @@ type command<K: Send, V: Send> = {key: K, val: V};
fn cache_server<K: Send, V: Send>(c: Chan<Chan<command<K, V>>>) {
let ctrl = Port();
send(c, Chan(ctrl));
send(c, Chan(&ctrl));
}
fn main() { }

View file

@ -14,6 +14,6 @@ fn foo(i:int, j: char) -> foo {
fn main() {
let po = comm::Port::<foo>();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
comm::send(ch, foo(42, 'c'));
}

View file

@ -15,6 +15,6 @@ fn iotask(cx: ctx, ip: ~str) {
fn main() {
let p = comm::Port::<int>();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
task::spawn(|| iotask(ch, ~"localhost") );
}

View file

@ -2,6 +2,6 @@ extern mod std;
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
comm::send(c, ~"coffee");
}

View file

@ -2,6 +2,6 @@ extern mod std;
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
comm::send(c, ~"coffee");
}

View file

@ -3,7 +3,7 @@ extern mod std;
fn main() {
let c = {
let p = comm::Port();
comm::Chan(p)
comm::Chan(&p)
};
comm::send(c, ~"coffee");
}

View file

@ -12,7 +12,7 @@ fn starship(&&ch: comm::Chan<~str>) {
fn starbase() {
for int::range(0, 10) |_i| {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
task::spawn(|| starship(c) );
task::yield();
}

View file

@ -7,7 +7,7 @@ extern mod std;
// or not this is desirable I don't know, but here's a regression test.
fn main() {
let po = comm::Port();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
comm::send(ch, ());
let n: () = comm::recv(po);
assert (n == ());

View file

@ -32,7 +32,7 @@ fn test00() {
debug!("Creating tasks");
let po = Port();
let ch = Chan(po);
let ch = Chan(&po);
let mut i: int = 0;
@ -69,7 +69,7 @@ fn test01() {
fn test02() {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
debug!("Writing to a local task channel.");
send(c, 42);
debug!("Reading from a local task port.");
@ -101,7 +101,7 @@ fn test05_start(ch: Chan<int>) {
fn test05() {
let po = comm::Port();
let ch = Chan(po);
let ch = Chan(&po);
task::spawn(|| test05_start(ch) );
let mut value: int;
value = recv(po);

View file

@ -36,7 +36,7 @@ fn joinable(+f: fn~()) -> comm::Port<bool> {
*b = true;
}
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
do task::spawn_unlinked { wrapper(c, copy f) };
p
}

View file

@ -1,6 +1,6 @@
fn main() {
let p = comm::Port::<uint>();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let x = ~1;
let x_in_parent = ptr::addr_of(&(*x)) as uint;

View file

@ -6,7 +6,7 @@ fn child(c: comm::Chan<~uint>, i: uint) {
fn main() {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let n = 100u;
let mut expected = 0u;
for uint::range(0u, n) |i| {

View file

@ -2,7 +2,7 @@ extern mod std;
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
comm::send(c, ~100);
let v = comm::recv(p);
assert v == ~100;

View file

@ -22,7 +22,7 @@ fn f(c: comm::Chan<bool>) {
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
task::spawn_unlinked(|| f(c) );
error!("hiiiiiiiii");
assert comm::recv(p);