Camel case various core constructors

This commit is contained in:
Brian Anderson 2012-08-27 14:22:25 -07:00
parent 4ba9fdd362
commit 161a82e433
113 changed files with 530 additions and 545 deletions

View file

@ -2,8 +2,7 @@
use std;
import comm::Chan;
import comm::chan;
import comm::port;
import comm::Port;
import comm::send;
import comm::recv;
import task;
@ -11,8 +10,8 @@ import task;
fn a(c: Chan<int>) { send(c, 10); }
fn main() {
let p = port();
let ch = chan(p);
let p = Port();
let ch = Chan(p);
task::spawn(|| a(ch) );
task::spawn(|| a(ch) );
let mut n: int = 0;

View file

@ -2,18 +2,17 @@
use std;
import comm;
import comm::port;
import comm::Port;
import comm::send;
import comm::Chan;
import comm::chan;
import comm::recv;
import task;
fn a(c: Chan<int>) { debug!("task a0"); debug!("task a1"); send(c, 10); }
fn main() {
let p = port();
let ch = chan(p);
let p = Port();
let ch = Chan(p);
task::spawn(|| a(ch) );
task::spawn(|| b(ch) );
let mut n: int = 0;

View file

@ -4,7 +4,6 @@ use std;
import comm;
import comm::send;
import comm::Chan;
import comm::chan;
import comm::recv;
import task;
@ -31,8 +30,8 @@ fn g(x: int, y: ~str) -> int {
fn main() {
let mut n: int = 2 + 3 * 7;
let s: ~str = ~"hello there";
let p = comm::port();
let ch = comm::chan(p);
let p = comm::Port();
let ch = comm::Chan(p);
task::spawn(|| a(ch) );
task::spawn(|| b(ch) );
let mut x: int = 10;

View file

@ -60,17 +60,17 @@ fn test_box() {
}
fn test_port() {
let p1 = comm::port::<int>();
let p2 = comm::port::<int>();
let p1 = comm::Port::<int>();
let p2 = comm::Port::<int>();
assert (p1 == p1);
assert (p1 != p2);
}
fn test_chan() {
let p: comm::Port<int> = comm::port();
let ch1 = comm::chan(p);
let ch2 = comm::chan(p);
let p: comm::Port<int> = comm::Port();
let ch1 = comm::Chan(p);
let ch2 = comm::Chan(p);
assert (ch1 == ch1);
// Chans are equal because they are just task:port addresses.

View file

@ -3,10 +3,9 @@
use std;
import task;
import comm::Chan;
import comm::chan;
import comm::send;
import comm;
import comm::port;
import comm::Port;
import comm::recv;
enum request { quit, close(Chan<bool>), }
@ -14,8 +13,8 @@ enum request { quit, close(Chan<bool>), }
type ctx = Chan<request>;
fn request_task(c: Chan<ctx>) {
let p = port();
send(c, chan(p));
let p = Port();
send(c, Chan(p));
let mut req: request;
req = recv(p);
// Need to drop req before receiving it again
@ -23,8 +22,8 @@ fn request_task(c: Chan<ctx>) {
}
fn new_cx() -> ctx {
let p = port();
let ch = chan(p);
let p = Port();
let ch = Chan(p);
let t = task::spawn(|| request_task(ch) );
let mut cx: ctx;
cx = recv(p);
@ -34,7 +33,7 @@ fn new_cx() -> ctx {
fn main() {
let cx = new_cx();
let p = port::<bool>();
send(cx, close(chan(p)));
let p = Port::<bool>();
send(cx, close(Chan(p)));
send(cx, quit);
}

View file

@ -3,14 +3,13 @@
use std;
import comm;
import comm::Chan;
import comm::chan;
import comm::send;
import comm::recv;
import task;
fn main() {
let p = comm::port();
let ch = comm::chan(p);
let p = comm::Port();
let ch = comm::Chan(p);
let t = task::spawn(|| child(ch) );
let y = recv(p);
error!("received");

View file

@ -1,14 +1,14 @@
// -*- rust -*-
use std;
import comm::port;
import comm::chan;
import comm::Port;
import comm::Chan;
import comm::send;
import comm::recv;
fn main() {
let po = port();
let ch = chan(po);
let po = Port();
let ch = Chan(po);
send(ch, 10);
let i = recv(po);
assert (i == 10);

View file

@ -1,5 +1,5 @@
fn main() {
let x = dvec::dvec();
let x = dvec::DVec();
x.push(1);
io::println(fmt!("%d", x[0]));
}

View file

@ -1,7 +1,7 @@
import dvec::dvec;
import dvec::DVec;
fn main() {
let d = dvec();
let d = DVec();
d.push(3);
d.push(4);
assert d.get() == ~[3, 4];

View file

@ -15,8 +15,7 @@ import std::map;
import std::map::hashmap;
import task;
import comm::Chan;
import comm::chan;
import comm::port;
import comm::Port;
import comm::send;
import comm::recv;
import comm;
@ -49,9 +48,9 @@ mod map_reduce {
match im.find(key) {
Some(_c) => { c = _c }
None => {
let p = port();
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);
@ -65,7 +64,7 @@ mod map_reduce {
}
fn map_reduce(inputs: ~[~str]) {
let ctrl = port();
let ctrl = Port();
// This task becomes the master control task. It spawns others
// to do the rest.
@ -74,7 +73,7 @@ mod map_reduce {
reducers = map::str_hash();
start_mappers(chan(ctrl), inputs);
start_mappers(Chan(ctrl), inputs);
let mut num_mappers = vec::len(inputs) as int;

View file

@ -10,9 +10,8 @@ use std;
import task;
import comm;
import comm::Chan;
import comm::chan;
import comm::send;
import comm::port;
import comm::Port;
import comm::recv;
fn grandchild(c: Chan<int>) { send(c, 42); }
@ -22,8 +21,8 @@ fn child(c: Chan<int>) {
}
fn main() {
let p = comm::port();
let ch = chan(p);
let p = comm::Port();
let ch = Chan(p);
task::spawn(|| child(ch) );

View file

@ -3,9 +3,7 @@ import vec;
import task;
import comm;
import comm::Chan;
import comm::chan;
import comm::Port;
import comm::port;
import comm::recv;
import comm::send;
@ -18,8 +16,8 @@ fn producer(c: Chan<~[u8]>) {
}
fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
let p: Port<~[u8]> = port();
send(cb, chan(p));
let p: Port<~[u8]> = Port();
send(cb, Chan(p));
loop {
debug!("waiting for bytes");
let data = recv(p);
@ -39,10 +37,10 @@ fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
}
fn main() {
let p: Port<msg> = port();
let ch = chan(p);
let recv_reader: Port<Chan<~[u8]>> = port();
let recv_reader_chan = chan(recv_reader);
let p: Port<msg> = Port();
let ch = Chan(p);
let recv_reader: Port<Chan<~[u8]>> = Port();
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

@ -5,11 +5,11 @@ import task::*;
fn a() {
fn doit() {
fn b(c: Chan<Chan<int>>) {
let p = port();
send(c, chan(p));
let p = Port();
send(c, Chan(p));
}
let p = port();
let ch = chan(p);
let p = Port();
let ch = Chan(p);
spawn(|| b(ch) );
recv(p);
}

View file

@ -3,9 +3,7 @@ use std;
import task;
import comm;
import comm::Chan;
import comm::chan;
import comm::Port;
import comm::port;
import comm::send;
import comm::recv;
@ -16,8 +14,8 @@ fn producer(c: Chan<~[u8]>) {
}
fn main() {
let p: Port<~[u8]> = port();
let ch = chan(p);
let p: Port<~[u8]> = Port();
let ch = Chan(p);
let prod = task::spawn(|| producer(ch) );
let data: ~[u8] = recv(p);

View file

@ -5,8 +5,8 @@ import task;
import comm::*;
fn main() {
let p = port();
let ch = chan(p);
let p = Port();
let ch = Chan(p);
let mut y: int;
task::spawn(|| child(ch) );

View file

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

View file

@ -50,7 +50,7 @@ fn main() {
calllink09,
calllink10
];
let rng = rand::rng();
let rng = rand::Rng();
for fns.each |f| {
let sz = rng.next() % 256u32 + 256u32;
let frame_backoff = rng.next() % 10u32 + 1u32;

View file

@ -6,8 +6,8 @@ use std;
import option;
import uint;
import comm;
import comm::port;
import comm::chan;
import comm::Port;
import comm::Chan;
import comm::send;
import comm::recv;
@ -20,8 +20,8 @@ type record = {val1: u32, val2: u32, val3: u32};
// power of two so needs to be rounded up. Don't trigger any
// assertions.
fn test_init() {
let myport = port();
let mychan = chan(myport);
let myport = Port();
let mychan = Chan(myport);
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
}
@ -30,8 +30,8 @@ fn test_init() {
// Dump lots of items into the channel so it has to grow.
// Don't trigger any assertions.
fn test_grow() {
let myport = port();
let mychan = chan(myport);
let myport = Port();
let mychan = Chan(myport);
for uint::range(0u, 100u) |i| {
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
comm::send(mychan, val);
@ -41,15 +41,15 @@ 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 myport = Port();
let mychan = Chan(myport);
send(mychan, 0i8);
let x = recv(myport);
}
fn test_shrink2() {
let myport = port();
let mychan = chan(myport);
let myport = Port();
let mychan = Chan(myport);
for uint::range(0u, 100u) |_i| {
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
@ -60,8 +60,8 @@ 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 myport = Port();
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);
@ -76,8 +76,8 @@ fn test_rotate() {
// Test rotating and growing the buffer when
// the unit size is not a power of two
fn test_rotate_grow() {
let myport = port::<record>();
let mychan = chan(myport);
let myport = Port::<record>();
let mychan = Chan(myport);
for uint::range(0u, 10u) |j| {
for uint::range(0u, 10u) |i| {
let val: record =

View file

@ -16,8 +16,8 @@ extern mod rustrt {
}
fn main() unsafe {
let po = comm::port();
let ch = comm::chan(po);
let po = comm::Port();
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

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

View file

@ -8,12 +8,12 @@ struct test {
}
fn main() {
let p = port();
let c = chan(p);
let p = Port();
let c = Chan(p);
do spawn() {
let p = port();
c.send(chan(p));
let p = Port();
c.send(Chan(p));
let _r = p.recv();
}

View file

@ -1,14 +1,13 @@
use std;
import comm::Chan;
import comm::chan;
import comm::send;
import comm::port;
import comm::Port;
// tests that ctrl's type gets inferred properly
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));
let ctrl = Port();
send(c, Chan(ctrl));
}
fn main() { }

View file

@ -7,7 +7,7 @@ struct foo {
}
fn main() {
let po = comm::port::<foo>();
let ch = comm::chan(po);
let po = comm::Port::<foo>();
let ch = comm::Chan(po);
comm::send(ch, foo(42, 'c'));
}

View file

@ -1,6 +1,6 @@
use std;
import comm::chan;
import comm::Chan;
import comm::send;
fn main() { test05(); }

View file

@ -1,6 +1,6 @@
use std;
import comm::chan;
import comm::Chan;
import comm::send;
fn main() { test05(); }

View file

@ -1,6 +1,6 @@
use std;
import comm::chan;
import comm::Chan;
import comm::send;
fn main() { test05(); }

View file

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

View file

@ -2,7 +2,7 @@ use std;
import comm;
fn main() {
let p = comm::port();
let c = comm::chan(p);
let p = comm::Port();
let c = comm::Chan(p);
comm::send(c, ~"coffee");
}

View file

@ -2,7 +2,7 @@ use std;
import comm;
fn main() {
let p = comm::port();
let c = comm::chan(p);
let p = comm::Port();
let c = comm::Chan(p);
comm::send(c, ~"coffee");
}

View file

@ -3,8 +3,8 @@ import comm;
fn main() {
let c = {
let p = comm::port();
comm::chan(p)
let p = comm::Port();
comm::Chan(p)
};
comm::send(c, ~"coffee");
}

View file

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

View file

@ -7,8 +7,8 @@ import comm;
// any size, but rustc currently can because they do have size. Whether
// 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 po = comm::Port();
let ch = comm::Chan(po);
comm::send(ch, ());
let n: () = comm::recv(po);
assert (n == ());

View file

@ -4,8 +4,7 @@ import task;
import task::task;
import comm;
import comm::Chan;
import comm::chan;
import comm::port;
import comm::Port;
import comm::send;
import comm::recv;
@ -34,8 +33,8 @@ fn test00() {
let number_of_messages: int = 4;
debug!("Creating tasks");
let po = port();
let ch = chan(po);
let po = Port();
let ch = Chan(po);
let mut i: int = 0;
@ -64,15 +63,15 @@ fn test00() {
}
fn test01() {
let p = port();
let p = Port();
debug!("Reading from a port that is never written to.");
let value: int = recv(p);
log(debug, value);
}
fn test02() {
let p = port();
let c = chan(p);
let p = Port();
let c = Chan(p);
debug!("Writing to a local task channel.");
send(c, 42);
debug!("Reading from a local task port.");
@ -103,8 +102,8 @@ fn test05_start(ch: Chan<int>) {
}
fn test05() {
let po = comm::port();
let ch = chan(po);
let po = comm::Port();
let ch = Chan(po);
task::spawn(|| test05_start(ch) );
let mut value: int;
value = recv(po);

View file

@ -30,8 +30,8 @@ fn joinable(+f: fn~()) -> comm::Port<bool> {
f();
*b = true;
}
let p = comm::port();
let c = comm::chan(p);
let p = comm::Port();
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 p = comm::Port::<uint>();
let ch = comm::Chan(p);
let x = ~1;
let x_in_parent = ptr::addr_of(*x) as uint;

View file

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

View file

@ -3,8 +3,8 @@ import comm;
import task;
fn main() {
let p = comm::port();
let c = comm::chan(p);
let p = comm::Port();
let c = comm::Chan(p);
comm::send(c, ~100);
let v = comm::recv(p);
assert v == ~100;

View file

@ -19,8 +19,8 @@ fn f(c: comm::Chan<bool>) {
}
fn main() {
let p = comm::port();
let c = comm::chan(p);
let p = comm::Port();
let c = comm::Chan(p);
task::spawn_unlinked(|| f(c) );
error!("hiiiiiiiii");
assert comm::recv(p);