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

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

View file

@ -35,7 +35,7 @@ fn main() {
let msg_per_task = uint::from_str(args[2]).get();
let num_port = Port();
let mut num_chan = Chan(num_port);
let mut num_chan = Chan(&num_port);
let start = time::precise_time_s();
@ -44,12 +44,12 @@ fn main() {
for uint::range(1u, num_tasks) |i| {
let get_chan = Port();
let get_chan_chan = Chan(get_chan);
let get_chan_chan = Chan(&get_chan);
let new_future = do future::spawn
|copy num_chan, move get_chan_chan| {
let p = Port();
get_chan_chan.send(Chan(p));
get_chan_chan.send(Chan(&p));
thread_ring(i, msg_per_task, num_chan, p)
};
futures.push(new_future);

View file

@ -126,8 +126,8 @@ fn rendezvous(nn: uint, set: ~[color]) {
let from_creatures_log: comm::Port<~str> = comm::Port();
// these channels will be passed to the creatures so they can talk to us
let to_rendezvous = comm::Chan(from_creatures);
let to_rendezvous_log = comm::Chan(from_creatures_log);
let to_rendezvous = comm::Chan(&from_creatures);
let to_rendezvous_log = comm::Chan(&from_creatures_log);
// these channels will allow us to talk to each creature by 'name'/index
let to_creature: ~[comm::Chan<Option<creature_info>>] =

View file

@ -142,7 +142,7 @@ fn main() {
// initialize each sequence sorter
let sizes = ~[1u,2u,3u,4u,6u,12u,18u];
let from_child = vec::map (sizes, |_sz| comm::Port() );
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(from_child[ii]) );
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(&from_child[ii]) );
let to_child = vec::mapi(sizes, |ii, sz| {
let ii = ii;
let sz = *sz;

View file

@ -103,7 +103,7 @@ impl devnull: io::Writer {
fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
{
let p: comm::Port<line> = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
comm::send(writech, ch);
let cout: io::Writer = match path {
~"" => {
@ -169,7 +169,7 @@ fn main() {
else { uint::from_str(args[1]).get() };
let writep = comm::Port();
let writech = comm::Chan(writep);
let writech = comm::Chan(&writep);
do task::spawn {
writer(path, writech, size);
};

View file

@ -7,7 +7,7 @@ fn start(+token: int) {
use iter::*;
let p = comm::Port();
let mut ch = comm::Chan(p);
let mut ch = comm::Chan(&p);
for int::range(2, n_threads + 1) |i| {
let id = n_threads + 2 - i;
let to_child = do task::spawn_listener::<int> |p, copy ch| {

View file

@ -11,7 +11,7 @@
// Doesn't return until all such tasks are ready, but doesn't block forever itself.
fn grandchild_group(num_tasks: uint) {
let po = comm::Port();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
for num_tasks.times {
do task::spawn { // linked

View file

@ -8,7 +8,7 @@ enum msg {
fn calc(children: uint, parent_ch: comm::Chan<msg>) {
let port = comm::Port();
let chan = comm::Chan(port);
let chan = comm::Chan(&port);
let mut child_chs = ~[];
let mut sum = 0;
@ -60,7 +60,7 @@ fn main() {
let children = uint::from_str(args[1]).get();
let port = comm::Port();
let chan = comm::Chan(port);
let chan = comm::Chan(&port);
do task::spawn {
calc(children, chan);
};

View file

@ -43,7 +43,7 @@ trait word_reader {
type joinable_task = Port<()>;
fn spawn_joinable(+f: fn~()) -> joinable_task {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do task::spawn() |move f| {
f();
c.send(());
@ -206,7 +206,7 @@ mod map_reduce {
{
let p = Port();
send(out, Chan(p));
send(out, Chan(&p));
let mut ref_count = 0;
let mut is_done = false;
@ -268,7 +268,7 @@ mod map_reduce {
None => {
// log(error, "creating new reducer for " + k);
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
let r = reduce, kk = k;
tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) ));
c = recv(p);

View file

@ -1,6 +1,6 @@
enum bottom { }
fn main() {
let x = ptr::p2::addr_of(&()) as *bottom;
let x = ptr::addr_of(&()) as *bottom;
match x { } //~ ERROR non-exhaustive patterns
}

View file

@ -1,5 +1,5 @@
fn main() {
let x : *~[int] = ptr::p2::addr_of(&~[1,2,3]);
let x : *~[int] = ptr::addr_of(&~[1,2,3]);
let y : *libc::c_void = x as *libc::c_void;
unsafe {
let _z = *y;

View file

@ -16,6 +16,6 @@ fn foo(i:int, j: @~str) -> foo {
fn main() {
let cat = ~"kitty";
let po = comm::Port(); //~ ERROR missing `send`
let ch = comm::Chan(po); //~ ERROR missing `send`
let ch = comm::Chan(&po); //~ ERROR missing `send`
comm::send(ch, foo(42, @cat)); //~ ERROR missing `send`
}

View file

@ -9,7 +9,7 @@ fn echo<T: Send>(c: Chan<T>, oc: Chan<Chan<T>>) {
// Tests that the type argument in port gets
// visited
let p = Port::<T>();
send(oc, Chan(p));
send(oc, Chan(&p));
let x = recv(p);
send(c, x);

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);