Camel case various core constructors
This commit is contained in:
parent
4ba9fdd362
commit
161a82e433
113 changed files with 530 additions and 545 deletions
14
doc/rust.md
14
doc/rust.md
|
@ -3030,8 +3030,8 @@ The result of a `spawn` call is a `core::task::task` value.
|
|||
An example of a `spawn` call:
|
||||
|
||||
~~~~
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
|
||||
do task::spawn {
|
||||
// let task run, do other things
|
||||
|
@ -3052,8 +3052,8 @@ channel's outgoing buffer.
|
|||
An example of a send:
|
||||
|
||||
~~~~
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
comm::send(ch, ~"hello, world");
|
||||
~~~~
|
||||
|
||||
|
@ -3061,15 +3061,15 @@ comm::send(ch, ~"hello, world");
|
|||
### Receiving values from ports
|
||||
|
||||
Receiving a value is done by a call to the `recv` method on a value of type
|
||||
`core::comm::port`. This call causes the receiving task to enter the *blocked
|
||||
`core::comm::Port`. This call causes the receiving task to enter the *blocked
|
||||
reading* state until a value arrives in the port's receive queue, at which
|
||||
time the port deques a value to return, and un-blocks the receiving task.
|
||||
|
||||
An example of a *receive*:
|
||||
|
||||
~~~~~~~~
|
||||
# let po = comm::port();
|
||||
# let ch = comm::chan(po);
|
||||
# let po = comm::Port();
|
||||
# let ch = comm::Chan(po);
|
||||
# comm::send(ch, ~"");
|
||||
let s = comm::recv(po);
|
||||
~~~~~~~~
|
||||
|
|
|
@ -2996,9 +2996,9 @@ message to the port. The next statement actually spawns the child:
|
|||
|
||||
~~~~
|
||||
# import task::{spawn};
|
||||
# import comm::{port, chan};
|
||||
# import comm::{Port, Chan};
|
||||
# fn some_expensive_computation() -> int { 42 }
|
||||
# let port = port();
|
||||
# let port = Port();
|
||||
# let chan = port.chan();
|
||||
do spawn {
|
||||
let result = some_expensive_computation();
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
import either::Either;
|
||||
import libc::size_t;
|
||||
|
||||
export Port, port;
|
||||
export Chan, chan;
|
||||
export Port;
|
||||
export Chan;
|
||||
export send;
|
||||
export recv;
|
||||
export peek;
|
||||
|
@ -69,13 +69,13 @@ enum Chan<T: send> {
|
|||
}
|
||||
|
||||
/// Constructs a port
|
||||
fn port<T: send>() -> Port<T> {
|
||||
fn Port<T: send>() -> Port<T> {
|
||||
Port_(@PortPtr(rustrt::new_port(sys::size_of::<T>() as size_t)))
|
||||
}
|
||||
|
||||
impl<T: send> Port<T> {
|
||||
|
||||
fn chan() -> Chan<T> { chan(self) }
|
||||
fn chan() -> Chan<T> { Chan(self) }
|
||||
fn send(+v: T) { self.chan().send(v) }
|
||||
fn recv() -> T { recv(self) }
|
||||
fn peek() -> bool { peek(self) }
|
||||
|
@ -93,7 +93,7 @@ impl<T: send> Chan<T> {
|
|||
|
||||
/// Open a new receiving channel for the duration of a function
|
||||
fn listen<T: send, U>(f: fn(Chan<T>) -> U) -> U {
|
||||
let po = port();
|
||||
let po = Port();
|
||||
f(po.chan())
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ fn as_raw_port<T: send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
|
|||
* Constructs a channel. The channel is bound to the port used to
|
||||
* construct it.
|
||||
*/
|
||||
fn chan<T: send>(p: Port<T>) -> Chan<T> {
|
||||
fn Chan<T: send>(p: Port<T>) -> Chan<T> {
|
||||
Chan_(rustrt::get_port_id((**p).po))
|
||||
}
|
||||
|
||||
|
@ -295,51 +295,51 @@ extern mod rusti {
|
|||
|
||||
|
||||
#[test]
|
||||
fn create_port_and_chan() { let p = port::<int>(); chan(p); }
|
||||
fn create_port_and_chan() { let p = Port::<int>(); Chan(p); }
|
||||
|
||||
#[test]
|
||||
fn send_int() {
|
||||
let p = port::<int>();
|
||||
let c = chan(p);
|
||||
let p = Port::<int>();
|
||||
let c = Chan(p);
|
||||
send(c, 22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_recv_fn() {
|
||||
let p = port::<int>();
|
||||
let c = chan::<int>(p);
|
||||
let p = Port::<int>();
|
||||
let c = Chan::<int>(p);
|
||||
send(c, 42);
|
||||
assert (recv(p) == 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_recv_fn_infer() {
|
||||
let p = port();
|
||||
let c = chan(p);
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
send(c, 42);
|
||||
assert (recv(p) == 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chan_chan_infer() {
|
||||
let p = port(), p2 = port::<int>();
|
||||
let c = chan(p);
|
||||
send(c, chan(p2));
|
||||
let p = Port(), p2 = Port::<int>();
|
||||
let c = Chan(p);
|
||||
send(c, Chan(p2));
|
||||
recv(p);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chan_chan() {
|
||||
let p = port::<Chan<int>>(), p2 = port::<int>();
|
||||
let c = chan(p);
|
||||
send(c, chan(p2));
|
||||
let p = Port::<Chan<int>>(), p2 = Port::<int>();
|
||||
let c = Chan(p);
|
||||
send(c, Chan(p2));
|
||||
recv(p);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_peek() {
|
||||
let po = port();
|
||||
let ch = chan(po);
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
assert !peek(po);
|
||||
send(ch, ());
|
||||
assert peek(po);
|
||||
|
@ -349,10 +349,10 @@ fn test_peek() {
|
|||
|
||||
#[test]
|
||||
fn test_select2_available() {
|
||||
let po_a = port();
|
||||
let po_b = port();
|
||||
let ch_a = chan(po_a);
|
||||
let ch_b = chan(po_b);
|
||||
let po_a = Port();
|
||||
let po_b = Port();
|
||||
let ch_a = Chan(po_a);
|
||||
let ch_b = Chan(po_b);
|
||||
|
||||
send(ch_a, ~"a");
|
||||
|
||||
|
@ -365,10 +365,10 @@ fn test_select2_available() {
|
|||
|
||||
#[test]
|
||||
fn test_select2_rendezvous() {
|
||||
let po_a = port();
|
||||
let po_b = port();
|
||||
let ch_a = chan(po_a);
|
||||
let ch_b = chan(po_b);
|
||||
let po_a = Port();
|
||||
let po_b = Port();
|
||||
let ch_a = Chan(po_a);
|
||||
let ch_b = Chan(po_b);
|
||||
|
||||
for iter::repeat(10u) {
|
||||
do task::spawn {
|
||||
|
@ -389,10 +389,10 @@ fn test_select2_rendezvous() {
|
|||
|
||||
#[test]
|
||||
fn test_select2_stress() {
|
||||
let po_a = port();
|
||||
let po_b = port();
|
||||
let ch_a = chan(po_a);
|
||||
let ch_b = chan(po_b);
|
||||
let po_a = Port();
|
||||
let po_b = Port();
|
||||
let ch_a = Chan(po_a);
|
||||
let ch_b = Chan(po_b);
|
||||
|
||||
let msgs = 100u;
|
||||
let times = 4u;
|
||||
|
@ -426,8 +426,8 @@ fn test_select2_stress() {
|
|||
|
||||
#[test]
|
||||
fn test_recv_chan() {
|
||||
let po = port();
|
||||
let ch = chan(po);
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
send(ch, ~"flower");
|
||||
assert recv_chan(ch) == ~"flower";
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ fn test_recv_chan() {
|
|||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_recv_chan_dead() {
|
||||
let ch = chan(port());
|
||||
let ch = Chan(Port());
|
||||
send(ch, ~"flower");
|
||||
recv_chan(ch);
|
||||
}
|
||||
|
@ -444,8 +444,8 @@ fn test_recv_chan_dead() {
|
|||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_recv_chan_wrong_task() {
|
||||
let po = port();
|
||||
let ch = chan(po);
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
send(ch, ~"flower");
|
||||
assert result::is_err(task::try(||
|
||||
recv_chan(ch)
|
||||
|
@ -454,14 +454,14 @@ fn test_recv_chan_wrong_task() {
|
|||
|
||||
#[test]
|
||||
fn test_port_send() {
|
||||
let po = port();
|
||||
let po = Port();
|
||||
po.send(());
|
||||
po.recv();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chan_peek() {
|
||||
let po = port();
|
||||
let po = Port();
|
||||
let ch = po.chan();
|
||||
ch.send(());
|
||||
assert ch.peek();
|
||||
|
@ -482,7 +482,7 @@ fn test_listen() {
|
|||
fn test_port_detach_fail() {
|
||||
for iter::repeat(100u) {
|
||||
do task::spawn_unlinked {
|
||||
let po = port();
|
||||
let po = Port();
|
||||
let ch = po.chan();
|
||||
|
||||
do task::spawn {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
|
||||
*/
|
||||
|
||||
export DList, dlist, dlist_node;
|
||||
export DList;
|
||||
export new_dlist, from_elem, from_vec, extensions;
|
||||
|
||||
type DListLink<T> = Option<DListNode<T>>;
|
||||
|
@ -20,11 +20,13 @@ enum DListNode<T> = @{
|
|||
mut next: DListLink<T>
|
||||
};
|
||||
|
||||
enum DList<T> = @{
|
||||
enum DList<T> {
|
||||
DList_(@{
|
||||
mut size: uint,
|
||||
mut hd: DListLink<T>,
|
||||
mut tl: DListLink<T>,
|
||||
};
|
||||
mut tl: DListLink<T>
|
||||
})
|
||||
}
|
||||
|
||||
priv impl<T> DListNode<T> {
|
||||
pure fn assert_links() {
|
||||
|
@ -83,19 +85,19 @@ pure fn new_dlist_node<T>(+data: T) -> DListNode<T> {
|
|||
}
|
||||
|
||||
/// Creates a new, empty dlist.
|
||||
pure fn new_dlist<T>() -> DList<T> {
|
||||
DList(@{mut size: 0, mut hd: None, mut tl: None})
|
||||
pure fn DList<T>() -> DList<T> {
|
||||
DList_(@{mut size: 0, mut hd: None, mut tl: None})
|
||||
}
|
||||
|
||||
/// Creates a new dlist with a single element
|
||||
pure fn from_elem<T>(+data: T) -> DList<T> {
|
||||
let list = new_dlist();
|
||||
let list = DList();
|
||||
unchecked { list.push(data); }
|
||||
list
|
||||
}
|
||||
|
||||
fn from_vec<T: copy>(+vec: &[T]) -> DList<T> {
|
||||
do vec::foldl(new_dlist(), vec) |list,data| {
|
||||
do vec::foldl(DList(), vec) |list,data| {
|
||||
list.push(data); // Iterating left-to-right -- add newly to the tail.
|
||||
list
|
||||
}
|
||||
|
@ -104,7 +106,7 @@ fn from_vec<T: copy>(+vec: &[T]) -> DList<T> {
|
|||
/// Produce a list from a list of lists, leaving no elements behind in the
|
||||
/// input. O(number of sub-lists).
|
||||
fn concat<T>(lists: DList<DList<T>>) -> DList<T> {
|
||||
let result = new_dlist();
|
||||
let result = DList();
|
||||
while !lists.is_empty() {
|
||||
result.append(lists.pop().get());
|
||||
}
|
||||
|
@ -485,7 +487,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_dlist_append_empty() {
|
||||
let a = from_vec(~[1,2,3]);
|
||||
let b = new_dlist::<int>();
|
||||
let b = DList::<int>();
|
||||
a.append(b);
|
||||
assert a.len() == 3;
|
||||
assert b.len() == 0;
|
||||
|
@ -497,7 +499,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_append_to_empty() {
|
||||
let a = new_dlist::<int>();
|
||||
let a = DList::<int>();
|
||||
let b = from_vec(~[4,5,6]);
|
||||
a.append(b);
|
||||
assert a.len() == 3;
|
||||
|
@ -510,8 +512,8 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_append_two_empty() {
|
||||
let a = new_dlist::<int>();
|
||||
let b = new_dlist::<int>();
|
||||
let a = DList::<int>();
|
||||
let b = DList::<int>();
|
||||
a.append(b);
|
||||
assert a.len() == 0;
|
||||
assert b.len() == 0;
|
||||
|
@ -522,14 +524,14 @@ mod tests {
|
|||
#[ignore(cfg(windows))]
|
||||
#[should_fail]
|
||||
fn test_dlist_append_self() {
|
||||
let a = new_dlist::<int>();
|
||||
let a = DList::<int>();
|
||||
a.append(a);
|
||||
}
|
||||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
#[should_fail]
|
||||
fn test_dlist_prepend_self() {
|
||||
let a = new_dlist::<int>();
|
||||
let a = DList::<int>();
|
||||
a.prepend(a);
|
||||
}
|
||||
#[test]
|
||||
|
@ -562,7 +564,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_reverse_empty() {
|
||||
let a = new_dlist::<int>();
|
||||
let a = DList::<int>();
|
||||
a.reverse();
|
||||
assert a.len() == 0;
|
||||
a.assert_consistent();
|
||||
|
@ -593,7 +595,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_is_empty() {
|
||||
let empty = new_dlist::<int>();
|
||||
let empty = DList::<int>();
|
||||
let full1 = from_vec(~[1,2,3]);
|
||||
assert empty.is_empty();
|
||||
assert !full1.is_empty();
|
||||
|
@ -635,7 +637,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_push() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.push(1);
|
||||
assert l.head() == 1;
|
||||
assert l.tail() == 1;
|
||||
|
@ -649,7 +651,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_push_head() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.push_head(3);
|
||||
assert l.head() == 3;
|
||||
assert l.tail() == 3;
|
||||
|
@ -678,7 +680,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_head() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
l.assert_consistent(); let _three = l.push_n(3);
|
||||
|
@ -693,7 +695,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_mid() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
l.assert_consistent(); let _three = l.push_n(3);
|
||||
|
@ -708,7 +710,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_tail() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
l.assert_consistent(); let three = l.push_n(3);
|
||||
|
@ -723,7 +725,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_one_two() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
l.assert_consistent(); let _three = l.push_n(3);
|
||||
|
@ -739,7 +741,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_one_three() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
l.assert_consistent(); let three = l.push_n(3);
|
||||
|
@ -754,7 +756,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_two_three() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
l.assert_consistent(); let three = l.push_n(3);
|
||||
|
@ -769,7 +771,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_remove_all() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
l.assert_consistent(); let three = l.push_n(3);
|
||||
|
@ -782,7 +784,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_insert_n_before() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
l.assert_consistent(); let three = new_dlist_node(3);
|
||||
|
@ -798,7 +800,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_insert_n_after() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
l.assert_consistent(); let three = new_dlist_node(3);
|
||||
|
@ -814,7 +816,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_insert_before_head() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let one = l.push_n(1);
|
||||
l.assert_consistent(); let _two = l.push_n(2);
|
||||
l.assert_consistent(); assert l.len() == 2;
|
||||
|
@ -829,7 +831,7 @@ mod tests {
|
|||
}
|
||||
#[test]
|
||||
fn test_dlist_insert_after_tail() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
l.assert_consistent(); let _one = l.push_n(1);
|
||||
l.assert_consistent(); let two = l.push_n(2);
|
||||
l.assert_consistent(); assert l.len() == 2;
|
||||
|
@ -844,7 +846,7 @@ mod tests {
|
|||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_asymmetric_link() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
let _one = l.push_n(1);
|
||||
let two = l.push_n(2);
|
||||
two.prev = None;
|
||||
|
@ -852,7 +854,7 @@ mod tests {
|
|||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_cyclic_list() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
let one = l.push_n(1);
|
||||
let _two = l.push_n(2);
|
||||
let three = l.push_n(3);
|
||||
|
@ -862,32 +864,32 @@ mod tests {
|
|||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_headless() {
|
||||
new_dlist::<int>().head();
|
||||
DList::<int>().head();
|
||||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_insert_already_present_before() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
let one = l.push_n(1);
|
||||
let two = l.push_n(2);
|
||||
l.insert_n_before(two, one);
|
||||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_insert_already_present_after() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
let one = l.push_n(1);
|
||||
let two = l.push_n(2);
|
||||
l.insert_n_after(one, two);
|
||||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_insert_before_orphan() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
let one = new_dlist_node(1);
|
||||
let two = new_dlist_node(2);
|
||||
l.insert_n_before(one, two);
|
||||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_dlist_insert_after_orphan() {
|
||||
let l = new_dlist::<int>();
|
||||
let l = DList::<int>();
|
||||
let one = new_dlist_node(1);
|
||||
let two = new_dlist_node(2);
|
||||
l.insert_n_after(two, one);
|
||||
|
|
|
@ -13,7 +13,6 @@ import unsafe::reinterpret_cast;
|
|||
import ptr::null;
|
||||
|
||||
export DVec;
|
||||
export dvec;
|
||||
export from_elem;
|
||||
export from_vec;
|
||||
export extensions;
|
||||
|
@ -59,7 +58,7 @@ enum DVec<A> {
|
|||
}
|
||||
|
||||
/// Creates a new, empty dvec
|
||||
fn dvec<A>() -> DVec<A> {
|
||||
fn DVec<A>() -> DVec<A> {
|
||||
DVec_({mut data: ~[mut]})
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ Basic input/output
|
|||
|
||||
import result::Result;
|
||||
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
|
||||
import libc::consts::os::posix88::*;
|
||||
import libc::consts::os::extra::*;
|
||||
|
@ -683,7 +683,7 @@ impl MemBuffer: Writer {
|
|||
}
|
||||
|
||||
fn mem_buffer() -> MemBuffer {
|
||||
@{buf: dvec(), mut pos: 0u}
|
||||
@{buf: DVec(), mut pos: 0u}
|
||||
}
|
||||
fn mem_buffer_writer(b: MemBuffer) -> Writer { b as Writer }
|
||||
fn mem_buffer_buf(b: MemBuffer) -> ~[u8] { b.buf.get() }
|
||||
|
|
|
@ -149,25 +149,25 @@ mod global_env {
|
|||
|
||||
fn getenv(n: &str) -> Option<~str> {
|
||||
let env_ch = get_global_env_chan();
|
||||
let po = comm::port();
|
||||
let po = comm::Port();
|
||||
comm::send(env_ch, MsgGetEnv(str::from_slice(n),
|
||||
comm::chan(po)));
|
||||
comm::Chan(po)));
|
||||
comm::recv(po)
|
||||
}
|
||||
|
||||
fn setenv(n: &str, v: &str) {
|
||||
let env_ch = get_global_env_chan();
|
||||
let po = comm::port();
|
||||
let po = comm::Port();
|
||||
comm::send(env_ch, MsgSetEnv(str::from_slice(n),
|
||||
str::from_slice(v),
|
||||
comm::chan(po)));
|
||||
comm::Chan(po)));
|
||||
comm::recv(po)
|
||||
}
|
||||
|
||||
fn env() -> ~[(~str,~str)] {
|
||||
let env_ch = get_global_env_chan();
|
||||
let po = comm::port();
|
||||
comm::send(env_ch, MsgEnv(comm::chan(po)));
|
||||
let po = comm::Port();
|
||||
comm::send(env_ch, MsgEnv(comm::Chan(po)));
|
||||
comm::recv(po)
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ mod tests {
|
|||
|
||||
fn make_rand_name() -> ~str {
|
||||
import rand;
|
||||
let rng: rand::Rng = rand::rng();
|
||||
let rng: rand::Rng = rand::Rng();
|
||||
let n = ~"TEST" + rng.gen_str(10u);
|
||||
assert option::is_none(getenv(n));
|
||||
n
|
||||
|
|
|
@ -47,8 +47,8 @@ unsafe fn chan_from_global_ptr<T: send>(
|
|||
|
||||
let (setup_po, setup_ch) = do task_fn().spawn_conversation
|
||||
|setup_po, setup_ch| {
|
||||
let po = comm::port::<T>();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port::<T>();
|
||||
let ch = comm::Chan(po);
|
||||
comm::send(setup_ch, ch);
|
||||
|
||||
// Wait to hear if we are the official instance of
|
||||
|
@ -105,8 +105,8 @@ fn test_from_global_chan1() {
|
|||
}
|
||||
};
|
||||
// Talk to it
|
||||
let po = comm::port();
|
||||
comm::send(ch, comm::chan(po));
|
||||
let po = comm::Port();
|
||||
comm::send(ch, comm::Chan(po));
|
||||
assert comm::recv(po) == true;
|
||||
|
||||
// This one just reuses the previous channel
|
||||
|
@ -118,8 +118,8 @@ fn test_from_global_chan1() {
|
|||
};
|
||||
|
||||
// Talk to the original global task
|
||||
let po = comm::port();
|
||||
comm::send(ch, comm::chan(po));
|
||||
let po = comm::Port();
|
||||
comm::send(ch, comm::Chan(po));
|
||||
assert comm::recv(po) == true;
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,8 @@ fn test_from_global_chan2() {
|
|||
let globchan = 0u;
|
||||
let globchanp = ptr::addr_of(globchan);
|
||||
|
||||
let resultpo = comm::port();
|
||||
let resultch = comm::chan(resultpo);
|
||||
let resultpo = comm::Port();
|
||||
let resultch = comm::Chan(resultpo);
|
||||
|
||||
// Spawn a bunch of tasks that all want to compete to
|
||||
// create the global channel
|
||||
|
@ -148,9 +148,9 @@ fn test_from_global_chan2() {
|
|||
}
|
||||
}
|
||||
};
|
||||
let po = comm::port();
|
||||
comm::send(ch, comm::chan(po));
|
||||
// We are the winner if our version of the
|
||||
let po = comm::Port();
|
||||
comm::send(ch, comm::Chan(po));
|
||||
// We are The winner if our version of the
|
||||
// task was installed
|
||||
let winner = comm::recv(po);
|
||||
comm::send(resultch, winner == i);
|
||||
|
@ -186,8 +186,8 @@ fn test_from_global_chan2() {
|
|||
* a reference to its parent, so the parent will not die.
|
||||
*/
|
||||
unsafe fn weaken_task(f: fn(comm::Port<()>)) {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
unsafe {
|
||||
rustrt::rust_task_weaken(unsafe::reinterpret_cast(ch));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Random number generation
|
||||
|
||||
export Rng, rng, seed, seeded_rng, Weighted, extensions;
|
||||
export Rng, seed, seeded_rng, Weighted, extensions;
|
||||
export xorshift, seeded_xorshift;
|
||||
|
||||
#[allow(non_camel_case_types)] // runtime type
|
||||
|
@ -259,7 +259,7 @@ fn seed() -> ~[u8] {
|
|||
}
|
||||
|
||||
/// Create a random number generator with a system specified seed
|
||||
fn rng() -> Rng {
|
||||
fn Rng() -> Rng {
|
||||
@RandRes(rustrt::rand_new()) as Rng
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn gen_int_range() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
let a = r.gen_int_range(-3, 42);
|
||||
assert a >= -3 && a < 42;
|
||||
assert r.gen_int_range(0, 1) == 0;
|
||||
|
@ -346,12 +346,12 @@ mod tests {
|
|||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn gen_int_from_fail() {
|
||||
rand::rng().gen_int_range(5, -2);
|
||||
rand::Rng().gen_int_range(5, -2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gen_uint_range() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
let a = r.gen_uint_range(3u, 42u);
|
||||
assert a >= 3u && a < 42u;
|
||||
assert r.gen_uint_range(0u, 1u) == 0u;
|
||||
|
@ -362,12 +362,12 @@ mod tests {
|
|||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn gen_uint_range_fail() {
|
||||
rand::rng().gen_uint_range(5u, 2u);
|
||||
rand::Rng().gen_uint_range(5u, 2u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gen_float() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
let a = r.gen_float();
|
||||
let b = r.gen_float();
|
||||
log(debug, (a, b));
|
||||
|
@ -375,14 +375,14 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn gen_weighted_bool() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
assert r.gen_weighted_bool(0u) == true;
|
||||
assert r.gen_weighted_bool(1u) == true;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gen_str() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
log(debug, r.gen_str(10u));
|
||||
log(debug, r.gen_str(10u));
|
||||
log(debug, r.gen_str(10u));
|
||||
|
@ -393,7 +393,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn gen_bytes() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
assert r.gen_bytes(0u).len() == 0u;
|
||||
assert r.gen_bytes(10u).len() == 10u;
|
||||
assert r.gen_bytes(16u).len() == 16u;
|
||||
|
@ -401,20 +401,20 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn choose() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
assert r.choose(~[1, 1, 1]) == 1;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn choose_option() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
assert r.choose_option(~[]) == None::<int>;
|
||||
assert r.choose_option(~[1, 1, 1]) == Some(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn choose_weighted() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
assert r.choose_weighted(~[{weight: 1u, item: 42}]) == 42;
|
||||
assert r.choose_weighted(~[
|
||||
{weight: 0u, item: 42},
|
||||
|
@ -424,7 +424,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn choose_weighted_option() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
assert r.choose_weighted_option(~[{weight: 1u, item: 42}]) ==
|
||||
Some(42);
|
||||
assert r.choose_weighted_option(~[
|
||||
|
@ -436,7 +436,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn weighted_vec() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
let empty: ~[int] = ~[];
|
||||
assert r.weighted_vec(~[]) == empty;
|
||||
assert r.weighted_vec(~[
|
||||
|
@ -448,7 +448,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn shuffle() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
let empty: ~[int] = ~[];
|
||||
assert r.shuffle(~[]) == empty;
|
||||
assert r.shuffle(~[1, 1, 1]) == ~[1, 1, 1];
|
||||
|
|
|
@ -297,8 +297,8 @@ fn program_output(prog: &str, args: &[~str]) ->
|
|||
// in parallel so we don't deadlock while blocking on one
|
||||
// or the other. FIXME (#2625): Surely there's a much more
|
||||
// clever way to do this.
|
||||
let p = comm::port();
|
||||
let ch = comm::chan(p);
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
do task::spawn_sched(task::SingleThreaded) {
|
||||
let errput = readclose(pipe_err.in);
|
||||
comm::send(ch, (2, errput));
|
||||
|
|
|
@ -39,7 +39,7 @@ mod linear {
|
|||
((capacity as float) * 3. / 4.) as uint
|
||||
}
|
||||
|
||||
fn linear_map<K,V>(
|
||||
fn LinearMap<K,V>(
|
||||
+hashfn: pure fn~(x: &K) -> uint,
|
||||
+eqfn: pure fn~(x: &K, y: &K) -> bool) -> LinearMap<K,V> {
|
||||
|
||||
|
@ -338,13 +338,13 @@ mod linear {
|
|||
#[test]
|
||||
mod test {
|
||||
|
||||
import linear::{LinearMap, linear_map};
|
||||
import linear::LinearMap;
|
||||
|
||||
pure fn uint_hash(x: &uint) -> uint { *x }
|
||||
pure fn uint_eq(x: &uint, y: &uint) -> bool { *x == *y }
|
||||
|
||||
fn int_linear_map<V>() -> LinearMap<uint,V> {
|
||||
return linear_map(uint_hash, uint_eq);
|
||||
return LinearMap(uint_hash, uint_eq);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -285,8 +285,8 @@ impl TaskBuilder {
|
|||
}
|
||||
|
||||
// Construct the future and give it to the caller.
|
||||
let po = comm::port::<Notification>();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port::<Notification>();
|
||||
let ch = comm::Chan(po);
|
||||
|
||||
blk(do future::from_fn {
|
||||
match comm::recv(po) {
|
||||
|
@ -368,11 +368,11 @@ impl TaskBuilder {
|
|||
* to the child.
|
||||
*/
|
||||
fn spawn_listener<A: send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
|
||||
let setup_po = comm::port();
|
||||
let setup_ch = comm::chan(setup_po);
|
||||
let setup_po = comm::Port();
|
||||
let setup_ch = comm::Chan(setup_po);
|
||||
do self.spawn {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
comm::send(setup_ch, ch);
|
||||
f(po);
|
||||
}
|
||||
|
@ -385,8 +385,8 @@ impl TaskBuilder {
|
|||
fn spawn_conversation<A: send, B: send>
|
||||
(+f: fn~(comm::Port<A>, comm::Chan<B>))
|
||||
-> (comm::Port<B>, comm::Chan<A>) {
|
||||
let from_child = comm::port();
|
||||
let to_parent = comm::chan(from_child);
|
||||
let from_child = comm::Port();
|
||||
let to_parent = comm::Chan(from_child);
|
||||
let to_child = do self.spawn_listener |from_parent| {
|
||||
f(from_parent, to_parent)
|
||||
};
|
||||
|
@ -407,8 +407,8 @@ impl TaskBuilder {
|
|||
* Fails if a future_result was already set for this task.
|
||||
*/
|
||||
fn try<T: send>(+f: fn~() -> T) -> Result<T,()> {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let mut result = None;
|
||||
|
||||
do self.future_result(|+r| { result = Some(r); }).spawn {
|
||||
|
@ -711,7 +711,7 @@ fn new_taskset() -> TaskSet {
|
|||
task1 == task2
|
||||
}
|
||||
|
||||
send_map::linear::linear_map(task_hash, task_eq)
|
||||
send_map::linear::LinearMap(task_hash, task_eq)
|
||||
}
|
||||
fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) {
|
||||
let didnt_overwrite = tasks.insert(task, ());
|
||||
|
@ -1295,7 +1295,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
|
|||
// drop when they finish. No "re-storing after modifying" is needed.
|
||||
let map_ptr = rustrt::rust_get_task_local_data(task);
|
||||
if map_ptr.is_null() {
|
||||
let map: TaskLocalMap = @dvec::dvec();
|
||||
let map: TaskLocalMap = @dvec::DVec();
|
||||
// Use reinterpret_cast -- transmute would take map away from us also.
|
||||
rustrt::rust_set_task_local_data(task, unsafe::reinterpret_cast(map));
|
||||
rustrt::rust_task_local_data_atexit(task, cleanup_task_local_map);
|
||||
|
@ -1494,8 +1494,8 @@ extern mod rustrt {
|
|||
|
||||
#[test]
|
||||
fn test_spawn_raw_simple() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
do spawn_raw(default_task_opts()) {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
|
@ -1532,8 +1532,8 @@ fn test_cant_dup_task_builder() {
|
|||
|
||||
#[test] #[ignore(cfg(windows))]
|
||||
fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
do spawn_unlinked {
|
||||
do spawn_unlinked {
|
||||
// Give middle task a chance to fail-but-not-kill-us.
|
||||
|
@ -1562,8 +1562,8 @@ fn test_spawn_unlinked_sup_fail_down() {
|
|||
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
|
||||
let po = comm::port::<()>();
|
||||
let _ch = comm::chan(po);
|
||||
let po = comm::Port::<()>();
|
||||
let _ch = comm::Chan(po);
|
||||
// Unidirectional "parenting" shouldn't override bidirectional linked.
|
||||
// We have to cheat with opts - the interface doesn't support them because
|
||||
// they don't make sense (redundant with task().supervised()).
|
||||
|
@ -1591,8 +1591,8 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
|
|||
}
|
||||
#[test] #[should_fail] #[ignore(cfg(windows))]
|
||||
fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails
|
||||
let po = comm::port::<()>();
|
||||
let _ch = comm::chan(po);
|
||||
let po = comm::Port::<()>();
|
||||
let _ch = comm::Chan(po);
|
||||
// Default options are to spawn linked & unsupervised.
|
||||
do spawn { fail; }
|
||||
comm::recv(po); // We should get punted awake
|
||||
|
@ -1664,10 +1664,10 @@ fn test_spawn_linked_sup_propagate_sibling() {
|
|||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_spawn_raw_notify() {
|
||||
let task_po = comm::port();
|
||||
let task_ch = comm::chan(task_po);
|
||||
let notify_po = comm::port();
|
||||
let notify_ch = comm::chan(notify_po);
|
||||
let task_po = comm::Port();
|
||||
let task_ch = comm::Chan(task_po);
|
||||
let notify_po = comm::Port();
|
||||
let notify_ch = comm::Chan(notify_po);
|
||||
|
||||
let opts = {
|
||||
notify_chan: Some(notify_ch)
|
||||
|
@ -1694,8 +1694,8 @@ fn test_spawn_raw_notify() {
|
|||
|
||||
#[test]
|
||||
fn test_run_basic() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
do task().spawn {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
|
@ -1704,8 +1704,8 @@ fn test_run_basic() {
|
|||
|
||||
#[test]
|
||||
fn test_add_wrapper() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let b0 = task();
|
||||
let b1 = do b0.add_wrapper |body| {
|
||||
fn~() {
|
||||
|
@ -1738,8 +1738,8 @@ fn test_back_to_the_future_result() {
|
|||
|
||||
#[test]
|
||||
fn test_spawn_listiner_bidi() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = do spawn_listener |po| {
|
||||
// Now the child has a port called 'po' to read from and
|
||||
// an environment-captured channel called 'ch'.
|
||||
|
@ -1794,8 +1794,8 @@ fn test_spawn_sched_no_threads() {
|
|||
|
||||
#[test]
|
||||
fn test_spawn_sched() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
|
||||
fn f(i: int, ch: comm::Chan<()>) {
|
||||
let parent_sched_id = rustrt::rust_get_sched_id();
|
||||
|
@ -1818,8 +1818,8 @@ fn test_spawn_sched() {
|
|||
|
||||
#[test]
|
||||
fn test_spawn_sched_childs_on_same_sched() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
|
||||
do spawn_sched(SingleThreaded) {
|
||||
let parent_sched_id = rustrt::rust_get_sched_id();
|
||||
|
@ -1852,10 +1852,10 @@ fn test_spawn_sched_blocking() {
|
|||
// without affecting other schedulers
|
||||
for iter::repeat(20u) {
|
||||
|
||||
let start_po = comm::port();
|
||||
let start_ch = comm::chan(start_po);
|
||||
let fin_po = comm::port();
|
||||
let fin_ch = comm::chan(fin_po);
|
||||
let start_po = comm::Port();
|
||||
let start_ch = comm::Chan(start_po);
|
||||
let fin_po = comm::Port();
|
||||
let fin_ch = comm::Chan(fin_po);
|
||||
|
||||
let lock = testrt::rust_dbg_lock_create();
|
||||
|
||||
|
@ -1882,13 +1882,13 @@ fn test_spawn_sched_blocking() {
|
|||
}
|
||||
}
|
||||
|
||||
let setup_po = comm::port();
|
||||
let setup_ch = comm::chan(setup_po);
|
||||
let parent_po = comm::port();
|
||||
let parent_ch = comm::chan(parent_po);
|
||||
let setup_po = comm::Port();
|
||||
let setup_ch = comm::Chan(setup_po);
|
||||
let parent_po = comm::Port();
|
||||
let parent_ch = comm::Chan(parent_po);
|
||||
do spawn {
|
||||
let child_po = comm::port();
|
||||
comm::send(setup_ch, comm::chan(child_po));
|
||||
let child_po = comm::Port();
|
||||
comm::send(setup_ch, comm::Chan(child_po));
|
||||
pingpong(child_po, parent_ch);
|
||||
};
|
||||
|
||||
|
@ -1905,8 +1905,8 @@ fn test_spawn_sched_blocking() {
|
|||
|
||||
#[cfg(test)]
|
||||
fn avoid_copying_the_body(spawnfn: fn(+fn~())) {
|
||||
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;
|
||||
|
@ -1972,8 +1972,8 @@ fn test_avoid_copying_the_body_unlinked() {
|
|||
|
||||
#[test]
|
||||
fn test_platform_thread() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
do task().sched_mode(PlatformThread).spawn {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
|
@ -1984,7 +1984,7 @@ fn test_platform_thread() {
|
|||
#[ignore(cfg(windows))]
|
||||
#[should_fail]
|
||||
fn test_unkillable() {
|
||||
let po = comm::port();
|
||||
let po = comm::Port();
|
||||
let ch = po.chan();
|
||||
|
||||
// We want to do this after failing
|
||||
|
@ -2020,7 +2020,7 @@ fn test_unkillable() {
|
|||
#[ignore(cfg(windows))]
|
||||
#[should_fail]
|
||||
fn test_unkillable_nested() {
|
||||
let po = comm::port();
|
||||
let po = comm::Port();
|
||||
let ch = po.chan();
|
||||
|
||||
// We want to do this after failing
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! A deque. Untested as of yet. Likely buggy
|
||||
|
||||
import option::{Some, None};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
trait t<T> {
|
||||
fn size() -> uint;
|
||||
|
|
|
@ -121,19 +121,19 @@ enum tcp_connect_err_data {
|
|||
fn connect(-input_ip: ip::ip_addr, port: uint,
|
||||
iotask: iotask)
|
||||
-> result::Result<tcp_socket, tcp_connect_err_data> unsafe {
|
||||
let result_po = core::comm::port::<conn_attempt>();
|
||||
let closed_signal_po = core::comm::port::<()>();
|
||||
let result_po = core::comm::Port::<conn_attempt>();
|
||||
let closed_signal_po = core::comm::Port::<()>();
|
||||
let conn_data = {
|
||||
result_ch: core::comm::chan(result_po),
|
||||
closed_signal_ch: core::comm::chan(closed_signal_po)
|
||||
result_ch: core::comm::Chan(result_po),
|
||||
closed_signal_ch: core::comm::Chan(closed_signal_po)
|
||||
};
|
||||
let conn_data_ptr = ptr::addr_of(conn_data);
|
||||
let reader_po = core::comm::port::<result::Result<~[u8], tcp_err_data>>();
|
||||
let reader_po = core::comm::Port::<result::Result<~[u8], tcp_err_data>>();
|
||||
let stream_handle_ptr = malloc_uv_tcp_t();
|
||||
*(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t();
|
||||
let socket_data = @{
|
||||
reader_po: reader_po,
|
||||
reader_ch: core::comm::chan(reader_po),
|
||||
reader_ch: core::comm::Chan(reader_po),
|
||||
stream_handle_ptr: stream_handle_ptr,
|
||||
connect_req: uv::ll::connect_t(),
|
||||
write_req: uv::ll::write_t(),
|
||||
|
@ -468,13 +468,13 @@ fn accept(new_conn: tcp_new_connection)
|
|||
new_tcp_conn(server_handle_ptr) => {
|
||||
let server_data_ptr = uv::ll::get_data_for_uv_handle(
|
||||
server_handle_ptr) as *tcp_listen_fc_data;
|
||||
let reader_po = core::comm::port();
|
||||
let reader_po = core::comm::Port();
|
||||
let iotask = (*server_data_ptr).iotask;
|
||||
let stream_handle_ptr = malloc_uv_tcp_t();
|
||||
*(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t();
|
||||
let client_socket_data = @{
|
||||
reader_po: reader_po,
|
||||
reader_ch: core::comm::chan(reader_po),
|
||||
reader_ch: core::comm::Chan(reader_po),
|
||||
stream_handle_ptr : stream_handle_ptr,
|
||||
connect_req : uv::ll::connect_t(),
|
||||
write_req : uv::ll::write_t(),
|
||||
|
@ -484,8 +484,8 @@ fn accept(new_conn: tcp_new_connection)
|
|||
let client_stream_handle_ptr =
|
||||
(*client_socket_data_ptr).stream_handle_ptr;
|
||||
|
||||
let result_po = core::comm::port::<Option<tcp_err_data>>();
|
||||
let result_ch = core::comm::chan(result_po);
|
||||
let result_po = core::comm::Port::<Option<tcp_err_data>>();
|
||||
let result_ch = core::comm::Chan(result_po);
|
||||
|
||||
// UNSAFE LIBUV INTERACTION BEGIN
|
||||
// .. normally this happens within the context of
|
||||
|
@ -581,14 +581,14 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
|
|||
on_establish_cb: fn~(comm::Chan<Option<tcp_err_data>>),
|
||||
-on_connect_cb: fn~(*uv::ll::uv_tcp_t))
|
||||
-> result::Result<(), tcp_listen_err_data> unsafe {
|
||||
let stream_closed_po = core::comm::port::<()>();
|
||||
let kill_po = core::comm::port::<Option<tcp_err_data>>();
|
||||
let kill_ch = core::comm::chan(kill_po);
|
||||
let stream_closed_po = core::comm::Port::<()>();
|
||||
let kill_po = core::comm::Port::<Option<tcp_err_data>>();
|
||||
let kill_ch = core::comm::Chan(kill_po);
|
||||
let server_stream = uv::ll::tcp_t();
|
||||
let server_stream_ptr = ptr::addr_of(server_stream);
|
||||
let server_data = {
|
||||
server_stream_ptr: server_stream_ptr,
|
||||
stream_closed_ch: core::comm::chan(stream_closed_po),
|
||||
stream_closed_ch: core::comm::Chan(stream_closed_po),
|
||||
kill_ch: kill_ch,
|
||||
on_connect_cb: on_connect_cb,
|
||||
iotask: iotask,
|
||||
|
@ -833,8 +833,8 @@ impl tcp_socket_buf: io::Writer {
|
|||
// INTERNAL API
|
||||
|
||||
fn tear_down_socket_data(socket_data: @tcp_socket_data) unsafe {
|
||||
let closed_po = core::comm::port::<()>();
|
||||
let closed_ch = core::comm::chan(closed_po);
|
||||
let closed_po = core::comm::Port::<()>();
|
||||
let closed_ch = core::comm::Chan(closed_po);
|
||||
let close_data = {
|
||||
closed_ch: closed_ch
|
||||
};
|
||||
|
@ -896,8 +896,8 @@ fn read_common_impl(socket_data: *tcp_socket_data, timeout_msecs: uint)
|
|||
fn read_stop_common_impl(socket_data: *tcp_socket_data) ->
|
||||
result::Result<(), tcp_err_data> unsafe {
|
||||
let stream_handle_ptr = (*socket_data).stream_handle_ptr;
|
||||
let stop_po = core::comm::port::<Option<tcp_err_data>>();
|
||||
let stop_ch = core::comm::chan(stop_po);
|
||||
let stop_po = core::comm::Port::<Option<tcp_err_data>>();
|
||||
let stop_ch = core::comm::Chan(stop_po);
|
||||
do iotask::interact((*socket_data).iotask) |loop_ptr| unsafe {
|
||||
log(debug, ~"in interact cb for tcp::read_stop");
|
||||
match uv::ll::read_stop(stream_handle_ptr as *uv::ll::uv_stream_t) {
|
||||
|
@ -923,8 +923,8 @@ fn read_start_common_impl(socket_data: *tcp_socket_data)
|
|||
-> result::Result<comm::Port<
|
||||
result::Result<~[u8], tcp_err_data>>, tcp_err_data> unsafe {
|
||||
let stream_handle_ptr = (*socket_data).stream_handle_ptr;
|
||||
let start_po = core::comm::port::<Option<uv::ll::uv_err_data>>();
|
||||
let start_ch = core::comm::chan(start_po);
|
||||
let start_po = core::comm::Port::<Option<uv::ll::uv_err_data>>();
|
||||
let start_ch = core::comm::Chan(start_po);
|
||||
log(debug, ~"in tcp::read_start before interact loop");
|
||||
do iotask::interact((*socket_data).iotask) |loop_ptr| unsafe {
|
||||
log(debug, fmt!("in tcp::read_start interact cb %?", loop_ptr));
|
||||
|
@ -961,9 +961,9 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data,
|
|||
vec::unsafe::to_ptr(raw_write_data),
|
||||
vec::len(raw_write_data)) ];
|
||||
let write_buf_vec_ptr = ptr::addr_of(write_buf_vec);
|
||||
let result_po = core::comm::port::<tcp_write_result>();
|
||||
let result_po = core::comm::Port::<tcp_write_result>();
|
||||
let write_data = {
|
||||
result_ch: core::comm::chan(result_po)
|
||||
result_ch: core::comm::Chan(result_po)
|
||||
};
|
||||
let write_data_ptr = ptr::addr_of(write_data);
|
||||
do iotask::interact((*socket_data_ptr).iotask) |loop_ptr| unsafe {
|
||||
|
@ -1278,11 +1278,11 @@ mod test {
|
|||
let expected_req = ~"ping";
|
||||
let expected_resp = ~"pong";
|
||||
|
||||
let server_result_po = core::comm::port::<~str>();
|
||||
let server_result_ch = core::comm::chan(server_result_po);
|
||||
let server_result_po = core::comm::Port::<~str>();
|
||||
let server_result_ch = core::comm::Chan(server_result_po);
|
||||
|
||||
let cont_po = core::comm::port::<()>();
|
||||
let cont_ch = core::comm::chan(cont_po);
|
||||
let cont_po = core::comm::Port::<()>();
|
||||
let cont_ch = core::comm::Chan(cont_po);
|
||||
// server
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
let actual_req = do comm::listen |server_ch| {
|
||||
|
@ -1344,11 +1344,11 @@ mod test {
|
|||
let expected_req = ~"ping";
|
||||
let expected_resp = ~"pong";
|
||||
|
||||
let server_result_po = core::comm::port::<~str>();
|
||||
let server_result_ch = core::comm::chan(server_result_po);
|
||||
let server_result_po = core::comm::Port::<~str>();
|
||||
let server_result_ch = core::comm::Chan(server_result_po);
|
||||
|
||||
let cont_po = core::comm::port::<()>();
|
||||
let cont_ch = core::comm::chan(cont_po);
|
||||
let cont_po = core::comm::Port::<()>();
|
||||
let cont_ch = core::comm::Chan(cont_po);
|
||||
// server
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
let actual_req = do comm::listen |server_ch| {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import map;
|
||||
import map::{hashmap, str_hash};
|
||||
import io::{Reader, ReaderUtil};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
export url, userinfo, query;
|
||||
export from_str, to_str;
|
||||
|
@ -217,7 +217,7 @@ fn decode_form_urlencoded(s: ~[u8]) ->
|
|||
let values = match m.find(key) {
|
||||
Some(values) => values,
|
||||
None => {
|
||||
let values = @dvec();
|
||||
let values = @DVec();
|
||||
m.insert(key, values);
|
||||
values
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ fn decode_form_urlencoded(s: ~[u8]) ->
|
|||
let values = match m.find(key) {
|
||||
Some(values) => values,
|
||||
None => {
|
||||
let values = @dvec();
|
||||
let values = @DVec();
|
||||
m.insert(key, values);
|
||||
values
|
||||
}
|
||||
|
@ -1010,8 +1010,8 @@ mod tests {
|
|||
let m = str_hash();
|
||||
assert encode_form_urlencoded(m) == ~"";
|
||||
|
||||
m.insert(~"", @dvec());
|
||||
m.insert(~"foo", @dvec());
|
||||
m.insert(~"", @DVec());
|
||||
m.insert(~"foo", @DVec());
|
||||
assert encode_form_urlencoded(m) == ~"";
|
||||
|
||||
let m = str_hash();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
import core::option;
|
||||
import core::option::{Some, None};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import map::map;
|
||||
|
||||
// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that
|
||||
|
@ -17,7 +17,7 @@ enum smallintmap<T:copy> {
|
|||
|
||||
/// Create a smallintmap
|
||||
fn mk<T: copy>() -> smallintmap<T> {
|
||||
let v = dvec();
|
||||
let v = DVec();
|
||||
return smallintmap_(@{v: v});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import option::{None, Some};
|
|||
import rand;
|
||||
|
||||
fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
let mut i = 0u;
|
||||
while (i < 1000u) {
|
||||
let p = tmpdir.push(r.gen_str(16u) +
|
||||
|
|
|
@ -286,8 +286,8 @@ fn run_tests(opts: test_opts, tests: ~[test_desc],
|
|||
let mut wait_idx = 0u;
|
||||
let mut done_idx = 0u;
|
||||
|
||||
let p = core::comm::port();
|
||||
let ch = core::comm::chan(p);
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
|
||||
while done_idx < total {
|
||||
while wait_idx < concurrency && run_idx < total {
|
||||
|
@ -420,8 +420,8 @@ mod tests {
|
|||
ignore: true,
|
||||
should_fail: false
|
||||
};
|
||||
let p = core::comm::port();
|
||||
let ch = core::comm::chan(p);
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res != tr_ok;
|
||||
|
@ -436,8 +436,8 @@ mod tests {
|
|||
ignore: true,
|
||||
should_fail: false
|
||||
};
|
||||
let p = core::comm::port();
|
||||
let ch = core::comm::chan(p);
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res == tr_ignored;
|
||||
|
@ -453,8 +453,8 @@ mod tests {
|
|||
ignore: false,
|
||||
should_fail: true
|
||||
};
|
||||
let p = core::comm::port();
|
||||
let ch = core::comm::chan(p);
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res == tr_ok;
|
||||
|
@ -469,8 +469,8 @@ mod tests {
|
|||
ignore: false,
|
||||
should_fail: true
|
||||
};
|
||||
let p = core::comm::port();
|
||||
let ch = core::comm::chan(p);
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res == tr_failed;
|
||||
|
|
|
@ -29,8 +29,8 @@ export delayed_send, sleep, recv_timeout;
|
|||
fn delayed_send<T: copy send>(iotask: iotask,
|
||||
msecs: uint, ch: comm::Chan<T>, +val: T) {
|
||||
unsafe {
|
||||
let timer_done_po = core::comm::port::<()>();
|
||||
let timer_done_ch = core::comm::chan(timer_done_po);
|
||||
let timer_done_po = core::comm::Port::<()>();
|
||||
let timer_done_ch = core::comm::Chan(timer_done_po);
|
||||
let timer_done_ch_ptr = ptr::addr_of(timer_done_ch);
|
||||
let timer = uv::ll::timer_t();
|
||||
let timer_ptr = ptr::addr_of(timer);
|
||||
|
@ -76,8 +76,8 @@ fn delayed_send<T: copy send>(iotask: iotask,
|
|||
* * msecs - an amount of time, in milliseconds, for the current task to block
|
||||
*/
|
||||
fn sleep(iotask: iotask, msecs: uint) {
|
||||
let exit_po = core::comm::port::<()>();
|
||||
let exit_ch = core::comm::chan(exit_po);
|
||||
let exit_po = core::comm::Port::<()>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
delayed_send(iotask, msecs, exit_ch, ());
|
||||
core::comm::recv(exit_po);
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ fn sleep(iotask: iotask, msecs: uint) {
|
|||
fn recv_timeout<T: copy send>(iotask: iotask,
|
||||
msecs: uint,
|
||||
wait_po: comm::Port<T>) -> Option<T> {
|
||||
let timeout_po = comm::port::<()>();
|
||||
let timeout_ch = comm::chan(timeout_po);
|
||||
let timeout_po = comm::Port::<()>();
|
||||
let timeout_ch = comm::Chan(timeout_po);
|
||||
delayed_send(iotask, msecs, timeout_ch, ());
|
||||
// FIXME: This could be written clearer (#2618)
|
||||
either::either(
|
||||
|
@ -163,8 +163,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_gl_timer_sleep_stress2() {
|
||||
let po = core::comm::port();
|
||||
let ch = core::comm::chan(po);
|
||||
let po = core::comm::Port();
|
||||
let ch = core::comm::Chan(po);
|
||||
let hl_loop = uv::global_loop::get();
|
||||
|
||||
let repeat = 20u;
|
||||
|
@ -182,7 +182,7 @@ mod test {
|
|||
let (times, maxms) = spec;
|
||||
do task::spawn {
|
||||
import rand::*;
|
||||
let rng = rng();
|
||||
let rng = Rng();
|
||||
for iter::repeat(times) {
|
||||
sleep(hl_loop, rng.next() as uint % maxms);
|
||||
}
|
||||
|
@ -240,9 +240,9 @@ mod test {
|
|||
let hl_loop = uv::global_loop::get();
|
||||
|
||||
for iter::repeat(times as uint) {
|
||||
let expected = rand::rng().gen_str(16u);
|
||||
let test_po = core::comm::port::<~str>();
|
||||
let test_ch = core::comm::chan(test_po);
|
||||
let expected = rand::Rng().gen_str(16u);
|
||||
let test_po = core::comm::Port::<~str>();
|
||||
let test_ch = core::comm::Chan(test_po);
|
||||
|
||||
do task::spawn() {
|
||||
delayed_send(hl_loop, 50u, test_ch, expected);
|
||||
|
|
|
@ -8,7 +8,7 @@ import get_gl = get;
|
|||
import iotask::{iotask, spawn_iotask};
|
||||
import priv::{chan_from_global_ptr, weaken_task};
|
||||
import comm = core::comm;
|
||||
import comm::{Port, Chan, port, chan, select2, listen};
|
||||
import comm::{Port, Chan, select2, listen};
|
||||
import task::TaskBuilder;
|
||||
import either::{Left, Right};
|
||||
|
||||
|
@ -132,8 +132,8 @@ mod test {
|
|||
}
|
||||
|
||||
fn impl_uv_hl_simple_timer(iotask: iotask) unsafe {
|
||||
let exit_po = core::comm::port::<bool>();
|
||||
let exit_ch = core::comm::chan(exit_po);
|
||||
let exit_po = core::comm::Port::<bool>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let exit_ch_ptr = ptr::addr_of(exit_ch);
|
||||
log(debug, fmt!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
|
||||
exit_ch_ptr));
|
||||
|
@ -165,8 +165,8 @@ mod test {
|
|||
#[test]
|
||||
fn test_gl_uv_global_loop_high_level_global_timer() unsafe {
|
||||
let hl_loop = get_gl();
|
||||
let exit_po = comm::port::<()>();
|
||||
let exit_ch = comm::chan(exit_po);
|
||||
let exit_po = comm::Port::<()>();
|
||||
let exit_ch = comm::Chan(exit_po);
|
||||
task::spawn_sched(task::ManualThreads(1u), || {
|
||||
impl_uv_hl_simple_timer(hl_loop);
|
||||
core::comm::send(exit_ch, ());
|
||||
|
@ -181,8 +181,8 @@ mod test {
|
|||
#[ignore]
|
||||
fn test_stress_gl_uv_global_loop_high_level_global_timer() unsafe {
|
||||
let hl_loop = get_gl();
|
||||
let exit_po = core::comm::port::<()>();
|
||||
let exit_ch = core::comm::chan(exit_po);
|
||||
let exit_po = core::comm::Port::<()>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let cycles = 5000u;
|
||||
for iter::repeat(cycles) {
|
||||
task::spawn_sched(task::ManualThreads(1u), || {
|
||||
|
|
|
@ -13,7 +13,7 @@ export exit;
|
|||
import libc::c_void;
|
||||
import ptr::addr_of;
|
||||
import comm = core::comm;
|
||||
import comm::{Port, port, Chan, chan, listen};
|
||||
import comm::{Port, Chan, listen};
|
||||
import task::TaskBuilder;
|
||||
import ll = uv_ll;
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn run_loop(iotask_ch: Chan<iotask>) unsafe {
|
|||
// initialize our loop data and store it in the loop
|
||||
let data: iotask_loop_data = {
|
||||
async_handle: async_handle,
|
||||
msg_po: port()
|
||||
msg_po: Port()
|
||||
};
|
||||
ll::set_data_for_uv_handle(async_handle, addr_of(data));
|
||||
|
||||
|
@ -186,8 +186,8 @@ mod test {
|
|||
fn impl_uv_iotask_async(iotask: iotask) unsafe {
|
||||
let async_handle = ll::async_t();
|
||||
let ah_ptr = ptr::addr_of(async_handle);
|
||||
let exit_po = core::comm::port::<()>();
|
||||
let exit_ch = core::comm::chan(exit_po);
|
||||
let exit_po = core::comm::Port::<()>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let ah_data = {
|
||||
iotask: iotask,
|
||||
exit_ch: exit_ch
|
||||
|
@ -204,8 +204,8 @@ mod test {
|
|||
// this fn documents the bear minimum neccesary to roll your own
|
||||
// high_level_loop
|
||||
unsafe fn spawn_test_loop(exit_ch: comm::Chan<()>) -> iotask {
|
||||
let iotask_port = comm::port::<iotask>();
|
||||
let iotask_ch = comm::chan(iotask_port);
|
||||
let iotask_port = comm::Port::<iotask>();
|
||||
let iotask_ch = comm::Chan(iotask_port);
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
run_loop(iotask_ch);
|
||||
exit_ch.send(());
|
||||
|
@ -225,8 +225,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_uv_iotask_async() unsafe {
|
||||
let exit_po = core::comm::port::<()>();
|
||||
let exit_ch = core::comm::chan(exit_po);
|
||||
let exit_po = core::comm::Port::<()>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let iotask = spawn_test_loop(exit_ch);
|
||||
|
||||
// using this handle to manage the lifetime of the high_level_loop,
|
||||
|
@ -235,8 +235,8 @@ mod test {
|
|||
// under race-condition type situations.. this ensures that the loop
|
||||
// lives until, at least, all of the impl_uv_hl_async() runs have been
|
||||
// called, at least.
|
||||
let work_exit_po = core::comm::port::<()>();
|
||||
let work_exit_ch = core::comm::chan(work_exit_po);
|
||||
let work_exit_po = core::comm::Port::<()>();
|
||||
let work_exit_ch = core::comm::Chan(work_exit_po);
|
||||
for iter::repeat(7u) {
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
impl_uv_iotask_async(iotask);
|
||||
|
|
|
@ -1461,13 +1461,13 @@ mod test {
|
|||
let port = 8887;
|
||||
let kill_server_msg = ~"does a dog have buddha nature?";
|
||||
let server_resp_msg = ~"mu!";
|
||||
let client_port = core::comm::port::<~str>();
|
||||
let client_chan = core::comm::chan::<~str>(client_port);
|
||||
let server_port = core::comm::port::<~str>();
|
||||
let server_chan = core::comm::chan::<~str>(server_port);
|
||||
let client_port = core::comm::Port::<~str>();
|
||||
let client_chan = core::comm::Chan::<~str>(client_port);
|
||||
let server_port = core::comm::Port::<~str>();
|
||||
let server_chan = core::comm::Chan::<~str>(server_port);
|
||||
|
||||
let continue_port = core::comm::port::<bool>();
|
||||
let continue_chan = core::comm::chan::<bool>(continue_port);
|
||||
let continue_port = core::comm::Port::<bool>();
|
||||
let continue_chan = core::comm::Chan::<bool>(continue_port);
|
||||
let continue_chan_ptr = ptr::addr_of(continue_chan);
|
||||
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
export filename;
|
||||
export filemap;
|
||||
|
@ -52,7 +52,7 @@ type codemap = @{files: DVec<filemap>};
|
|||
|
||||
type loc = {file: filemap, line: uint, col: uint};
|
||||
|
||||
fn new_codemap() -> codemap { @{files: dvec()} }
|
||||
fn new_codemap() -> codemap { @{files: DVec()} }
|
||||
|
||||
fn new_filemap_w_substr(+filename: filename, +substr: file_substr,
|
||||
src: @~str,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import to_str::ToStr;
|
||||
|
||||
import dvec::dvec;
|
||||
import dvec::DVec;
|
||||
|
||||
import ast::ident;
|
||||
import util::interner;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import to_str::ToStr;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
import ast_builder::{path, append_types};
|
||||
|
||||
|
@ -119,7 +119,7 @@ struct protocol_ {
|
|||
new(name: ~str, span: span) {
|
||||
self.name = name;
|
||||
self.span = span;
|
||||
self.states = dvec();
|
||||
self.states = DVec();
|
||||
self.bounded = None;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ struct protocol_ {
|
|||
impl protocol {
|
||||
fn add_state_poly(name: ~str, ident: ast::ident, dir: direction,
|
||||
+ty_params: ~[ast::ty_param]) -> state {
|
||||
let messages = dvec();
|
||||
let messages = DVec();
|
||||
|
||||
let state = state_(@{
|
||||
id: self.states.len(),
|
||||
|
|
|
@ -2,7 +2,7 @@ import ast::{crate, expr_, mac_invoc,
|
|||
mac_aq, mac_var};
|
||||
import parse::parser;
|
||||
import parse::parser::parse_from_source_str;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import parse::token::ident_interner;
|
||||
|
||||
import fold::*;
|
||||
|
@ -119,7 +119,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt
|
|||
let v = @{visit_expr: |node, &&cx, v| visit_aq(node, ~"from_expr", cx, v),
|
||||
visit_ty: |node, &&cx, v| visit_aq(node, ~"from_ty", cx, v)
|
||||
with *default_visitor()};
|
||||
let cx = @{lo:lo, gather: dvec()};
|
||||
let cx = @{lo:lo, gather: DVec()};
|
||||
node.visit(cx, mk_vt(v));
|
||||
// FIXME (#2250): Maybe this is an overkill (merge_sort), it might
|
||||
// be better to just keep the gather array in sorted order.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import codemap::span;
|
||||
import std::map::{hashmap, str_hash, uint_hash};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
import base::*;
|
||||
|
||||
|
@ -136,7 +136,7 @@ fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
|
|||
fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
|
||||
let res: binders =
|
||||
{real_binders: uint_hash::<selector>(),
|
||||
literal_ast_matchers: dvec()};
|
||||
literal_ast_matchers: DVec()};
|
||||
//this oughta return binders instead, but macro args are a sequence of
|
||||
//expressions, rather than a single expression
|
||||
fn trivial_selector(m: matchable) -> match_result {
|
||||
|
|
|
@ -7,7 +7,7 @@ import parse::parser::{parser,SOURCE_FILE};
|
|||
//import parse::common::parser_common;
|
||||
import parse::common::*; //resolve bug?
|
||||
import parse::parse_sess;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import ast::{matcher, match_tok, match_seq, match_nonterminal, ident};
|
||||
import ast_util::mk_sp;
|
||||
import std::map::{hashmap, uint_hash};
|
||||
|
@ -137,7 +137,7 @@ fn initial_matcher_pos(ms: ~[matcher], sep: Option<token>, lo: uint)
|
|||
}
|
||||
}
|
||||
~{elts: ms, sep: sep, mut idx: 0u, mut up: matcher_pos_up(None),
|
||||
matches: copy vec::from_fn(count_names(ms), |_i| dvec::dvec()),
|
||||
matches: copy vec::from_fn(count_names(ms), |_i| dvec::DVec()),
|
||||
match_lo: 0u, match_hi: match_idx_hi, sp_lo: lo}
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
|
|||
}
|
||||
|
||||
let matches = vec::map(ei.matches, // fresh, same size:
|
||||
|_m| dvec::<@named_match>());
|
||||
|_m| DVec::<@named_match>());
|
||||
let ei_t <- ei;
|
||||
vec::push(cur_eis, ~{
|
||||
elts: matchers, sep: sep, mut idx: 0u,
|
||||
|
|
|
@ -13,7 +13,7 @@ import prec::{as_prec, token_to_binop};
|
|||
import attr::parser_attr;
|
||||
import common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed,
|
||||
seq_sep_none, token_to_str};
|
||||
import dvec::dvec;
|
||||
import dvec::DVec;
|
||||
import vec::{push};
|
||||
import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
||||
|
@ -3427,7 +3427,7 @@ struct parser {
|
|||
items_allowed = false
|
||||
}
|
||||
|
||||
let (view_items, items) = (dvec(), dvec());
|
||||
let (view_items, items) = (DVec(), DVec());
|
||||
loop {
|
||||
match self.parse_item_or_view_item(attrs, items_allowed) {
|
||||
iovi_none =>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import io::WriterUtil;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
/*
|
||||
* This pretty-printer is a direct reimplementation of Philip Karlton's
|
||||
|
@ -117,7 +117,7 @@ fn mk_printer(out: io::Writer, linewidth: uint) -> printer {
|
|||
mut scan_stack_empty: true,
|
||||
mut top: 0u,
|
||||
mut bottom: 0u,
|
||||
print_stack: dvec(),
|
||||
print_stack: DVec(),
|
||||
mut pending_indentation: 0,
|
||||
mut token_tree_last_was_ident: false})
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import pp::{break_offset, word, printer,
|
|||
import diagnostic;
|
||||
import ast::{required, provided};
|
||||
import ast_util::{operator_prec};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import parse::classify::*;
|
||||
import parse::token::ident_interner;
|
||||
|
||||
|
@ -53,7 +53,7 @@ fn rust_printer(writer: io::Writer, intr: ident_interner) -> ps {
|
|||
literals: None::<~[comments::lit]>,
|
||||
mut cur_cmnt: 0u,
|
||||
mut cur_lit: 0u,
|
||||
boxes: dvec(),
|
||||
boxes: DVec(),
|
||||
ann: no_ann()};
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ fn print_crate(cm: codemap, intr: ident_interner,
|
|||
literals: if is_expanded { None } else { Some(r.lits) },
|
||||
mut cur_cmnt: 0u,
|
||||
mut cur_lit: 0u,
|
||||
boxes: dvec(),
|
||||
boxes: DVec(),
|
||||
ann: ann};
|
||||
print_crate_(s, crate);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// type, and vice versa.
|
||||
import std::map;
|
||||
import std::map::{hashmap, hashfn, eqfn};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
type hash_interner<T: const> =
|
||||
{map: hashmap<T, uint>,
|
||||
|
@ -14,7 +14,7 @@ type hash_interner<T: const> =
|
|||
fn mk<T: const copy>(+hasher: hashfn<T>, +eqer: eqfn<T>) -> interner<T> {
|
||||
let m = map::hashmap::<T, uint>(copy hasher, copy eqer);
|
||||
let hi: hash_interner<T> =
|
||||
{map: m, vect: dvec(), hasher: hasher, eqer: eqer};
|
||||
{map: m, vect: DVec(), hasher: hasher, eqer: eqer};
|
||||
return hi as interner::<T>;
|
||||
}
|
||||
|
||||
|
|
|
@ -217,8 +217,8 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
|
|||
done,
|
||||
};
|
||||
|
||||
let p = comm::port();
|
||||
let ch = comm::chan(p);
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
|
||||
match do task::try {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import syntax::codemap::span;
|
|||
import driver::session;
|
||||
import session::session;
|
||||
import syntax::attr;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
export modify_for_testing;
|
||||
|
||||
|
@ -42,7 +42,7 @@ fn generate_test_harness(sess: session::session,
|
|||
@{sess: sess,
|
||||
crate: crate,
|
||||
mut path: ~[],
|
||||
testfns: dvec()};
|
||||
testfns: DVec()};
|
||||
|
||||
let precursor =
|
||||
@{fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),
|
||||
|
|
|
@ -9,7 +9,7 @@ import std::map::{hashmap, int_hash};
|
|||
import syntax::print::pprust;
|
||||
import filesearch::filesearch;
|
||||
import common::*;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import syntax::parse::token::ident_interner;
|
||||
|
||||
export read_crates;
|
||||
|
@ -24,7 +24,7 @@ fn read_crates(diag: span_handler, crate: ast::crate,
|
|||
cstore: cstore,
|
||||
os: os,
|
||||
static: static,
|
||||
crate_cache: dvec(),
|
||||
crate_cache: DVec(),
|
||||
mut next_crate_num: 1,
|
||||
intr: intr};
|
||||
let v =
|
||||
|
|
|
@ -11,7 +11,7 @@ import syntax::diagnostic::expect;
|
|||
import ast_util::dummy_sp;
|
||||
import common::*;
|
||||
import std::map::hashmap;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
export class_dtor;
|
||||
export get_symbol;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import std::{ebml, map};
|
||||
import std::map::{hashmap, str_hash};
|
||||
import io::WriterUtil;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import syntax::{ast, ast_util};
|
||||
import syntax::attr;
|
||||
import middle::ty;
|
||||
|
@ -714,7 +714,7 @@ fn get_method_names_if_trait(intr: ident_interner, cdata: cmd,
|
|||
return None;
|
||||
}
|
||||
|
||||
let resulting_methods = @dvec();
|
||||
let resulting_methods = @DVec();
|
||||
for ebml::tagged_docs(item, tag_item_trait_method) |method| {
|
||||
resulting_methods.push(
|
||||
(item_name(intr, method), get_self_ty(method)));
|
||||
|
|
|
@ -229,7 +229,7 @@ import syntax::print::pprust;
|
|||
import util::common::indenter;
|
||||
import ty::to_str;
|
||||
import driver::session::session;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import mem_categorization::*;
|
||||
|
||||
export check_crate, root_map, mutbl_map;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// 3. assignments do not affect things loaned out as immutable
|
||||
// 4. moves to dnot affect things loaned out in any way
|
||||
|
||||
import dvec::dvec;
|
||||
import dvec::DVec;
|
||||
|
||||
export check_loans;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ impl borrowck_ctxt {
|
|||
mutbl: ast::mutability) -> bckres<@DVec<loan>> {
|
||||
let lc = loan_ctxt_(@{bccx: self,
|
||||
scope_region: scope_region,
|
||||
loans: @dvec()});
|
||||
loans: @DVec()});
|
||||
match lc.loan(cmt, mutbl) {
|
||||
Ok(()) => {Ok(lc.loans)}
|
||||
Err(e) => {Err(e)}
|
||||
|
|
|
@ -2,7 +2,7 @@ import syntax::ast::*;
|
|||
import syntax::{visit, ast_util, ast_map};
|
||||
import driver::session::session;
|
||||
import std::map::hashmap;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map,
|
||||
def_map: resolve3::DefMap,
|
||||
|
@ -158,7 +158,7 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map,
|
|||
sess: sess,
|
||||
ast_map: ast_map,
|
||||
def_map: def_map,
|
||||
idstack: @dvec()
|
||||
idstack: @DVec()
|
||||
};
|
||||
|
||||
let visitor = visit::mk_vt(@{
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
* - `self_var`: a variable representing 'self'
|
||||
*/
|
||||
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import std::map::{hashmap, int_hash, str_hash, uint_hash};
|
||||
import syntax::{visit, ast_util};
|
||||
import syntax::print::pprust::{expr_to_str};
|
||||
|
@ -348,7 +348,7 @@ impl IrMaps {
|
|||
let v = match self.last_use_map.find(expr_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
let v = @dvec();
|
||||
let v = @DVec();
|
||||
self.last_use_map.insert(expr_id, v);
|
||||
v
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import syntax::codemap::span;
|
|||
import syntax::print::pprust;
|
||||
import syntax::ast_util::new_def_hash;
|
||||
import syntax::ast_map;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import metadata::csearch;
|
||||
import ty::{region_variance, rv_covariant, rv_invariant, rv_contravariant};
|
||||
|
||||
|
@ -468,7 +468,7 @@ impl determine_rp_ctxt {
|
|||
let vec = match self.dep_map.find(from) {
|
||||
Some(vec) => vec,
|
||||
None => {
|
||||
let vec = @dvec();
|
||||
let vec = @DVec();
|
||||
self.dep_map.insert(from, vec);
|
||||
vec
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ fn determine_rp_in_crate(sess: session,
|
|||
def_map: def_map,
|
||||
region_paramd_items: int_hash(),
|
||||
dep_map: int_hash(),
|
||||
worklist: dvec(),
|
||||
worklist: DVec(),
|
||||
mut item_id: 0,
|
||||
mut anon_implies_rp: false,
|
||||
mut ambient_variance: rv_covariant});
|
||||
|
|
|
@ -53,7 +53,7 @@ import syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};
|
|||
import syntax::visit::{visit_mod, visit_ty, vt};
|
||||
|
||||
import box::ptr_eq;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import option::{get, is_some};
|
||||
import str::{connect, split_str};
|
||||
import vec::pop;
|
||||
|
@ -384,7 +384,7 @@ struct Module {
|
|||
self.def_id = def_id;
|
||||
|
||||
self.children = atom_hashmap();
|
||||
self.imports = dvec();
|
||||
self.imports = DVec();
|
||||
|
||||
self.anonymous_children = int_hash();
|
||||
|
||||
|
@ -654,9 +654,9 @@ struct Resolver {
|
|||
self.unresolved_imports = 0u;
|
||||
|
||||
self.current_module = (*self.graph_root).get_module();
|
||||
self.value_ribs = @dvec();
|
||||
self.type_ribs = @dvec();
|
||||
self.label_ribs = @dvec();
|
||||
self.value_ribs = @DVec();
|
||||
self.type_ribs = @DVec();
|
||||
self.label_ribs = @DVec();
|
||||
|
||||
self.xray_context = NoXray;
|
||||
self.current_trait_refs = None;
|
||||
|
@ -1069,7 +1069,7 @@ struct Resolver {
|
|||
// globs and lists, the path is found directly in the AST;
|
||||
// for simple paths we have to munge the path a little.
|
||||
|
||||
let module_path = @dvec();
|
||||
let module_path = @DVec();
|
||||
match view_path.node {
|
||||
view_path_simple(_, full_path, _) => {
|
||||
let path_len = full_path.idents.len();
|
||||
|
@ -3304,7 +3304,7 @@ struct Resolver {
|
|||
// Resolve the trait reference, if necessary.
|
||||
let original_trait_refs = self.current_trait_refs;
|
||||
if trait_references.len() >= 1 {
|
||||
let mut new_trait_refs = @dvec();
|
||||
let mut new_trait_refs = @DVec();
|
||||
for trait_references.each |trait_reference| {
|
||||
match self.resolve_path(
|
||||
trait_reference.path, TypeNS, true, visitor) {
|
||||
|
@ -3893,7 +3893,7 @@ struct Resolver {
|
|||
}
|
||||
|
||||
fn intern_module_part_of_path(path: @path) -> @DVec<Atom> {
|
||||
let module_path_atoms = @dvec();
|
||||
let module_path_atoms = @DVec();
|
||||
for path.idents.eachi |index, ident| {
|
||||
if index == path.idents.len() - 1u {
|
||||
break;
|
||||
|
@ -4304,7 +4304,7 @@ struct Resolver {
|
|||
}
|
||||
|
||||
fn search_for_traits_containing_method(name: Atom) -> @DVec<def_id> {
|
||||
let found_traits = @dvec();
|
||||
let found_traits = @DVec();
|
||||
let mut search_module = self.current_module;
|
||||
loop {
|
||||
// Look for the current trait.
|
||||
|
@ -4406,7 +4406,7 @@ struct Resolver {
|
|||
}
|
||||
|
||||
fn add_fixed_trait_for_expr(expr_id: node_id, +trait_id: Option<def_id>) {
|
||||
let traits = @dvec();
|
||||
let traits = @DVec();
|
||||
traits.push(trait_id.get());
|
||||
self.trait_map.insert(expr_id, traits);
|
||||
}
|
||||
|
@ -4503,7 +4503,7 @@ struct Resolver {
|
|||
|
||||
/// A somewhat inefficient routine to print out the name of a module.
|
||||
fn module_to_str(module_: @Module) -> ~str {
|
||||
let atoms = dvec();
|
||||
let atoms = DVec();
|
||||
let mut current_module = module_;
|
||||
loop {
|
||||
match current_module.parent_link {
|
||||
|
|
|
@ -13,7 +13,7 @@ import syntax::print::pprust::pat_to_str;
|
|||
import middle::resolve3::DefMap;
|
||||
import back::abi;
|
||||
import std::map::hashmap;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
import common::*;
|
||||
|
||||
|
@ -282,7 +282,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
|
|||
set.push(val);
|
||||
}
|
||||
|
||||
let found = dvec();
|
||||
let found = DVec();
|
||||
for vec::each(m) |br| {
|
||||
let cur = br.pats[col];
|
||||
if pat_is_variant(ccx.tcx.def_map, cur) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import syntax::ast_util::{dummy_sp, new_def_hash};
|
|||
import syntax::util::interner;
|
||||
import util::ppaux::ty_to_str;
|
||||
import syntax::codemap::span;
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
import std::map::hashmap;
|
||||
import option::is_some;
|
||||
|
@ -192,7 +192,7 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
|||
return {mut next_tag_id: 0u16,
|
||||
pad: 0u16,
|
||||
tag_id_to_index: new_nominal_id_hash(),
|
||||
tag_order: dvec(),
|
||||
tag_order: DVec(),
|
||||
resources: interner::mk(hash_nominal_id, eq_nominal_id),
|
||||
llshapetablesty: llshapetablesty,
|
||||
llshapetables: llshapetables};
|
||||
|
|
|
@ -9,7 +9,7 @@ import syntax::ast::{sty_value, by_ref, by_copy};
|
|||
import syntax::ast_map;
|
||||
import syntax::ast_map::node_id_to_str;
|
||||
import syntax::ast_util::{dummy_sp, new_def_hash};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
enum method_lookup_mode {
|
||||
subtyping_mode,
|
||||
|
@ -98,7 +98,7 @@ struct lookup {
|
|||
self.m_name = m_name;
|
||||
self.self_ty = self_ty;
|
||||
self.derefs = 0u;
|
||||
self.candidates = dvec();
|
||||
self.candidates = DVec();
|
||||
self.candidate_impls = new_def_hash();
|
||||
self.supplied_tps = supplied_tps;
|
||||
self.include_private = include_private;
|
||||
|
|
|
@ -30,7 +30,7 @@ import syntax::visit::{mk_simple_visitor, mk_vt, visit_crate, visit_item};
|
|||
import syntax::visit::{visit_mod};
|
||||
import util::ppaux::ty_to_str;
|
||||
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import result::Ok;
|
||||
import std::map::{hashmap, int_hash};
|
||||
import uint::range;
|
||||
|
@ -329,7 +329,7 @@ struct CoherenceChecker {
|
|||
.find(base_def_id) {
|
||||
|
||||
None => {
|
||||
implementation_list = @dvec();
|
||||
implementation_list = @DVec();
|
||||
self.crate_context.coherence_info.inherent_methods
|
||||
.insert(base_def_id, implementation_list);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ struct CoherenceChecker {
|
|||
.find(trait_id) {
|
||||
|
||||
None => {
|
||||
implementation_list = @dvec();
|
||||
implementation_list = @DVec();
|
||||
self.crate_context.coherence_info.extension_methods
|
||||
.insert(trait_id, implementation_list);
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ struct CoherenceChecker {
|
|||
}
|
||||
|
||||
fn gather_privileged_types(items: ~[@item]) -> @DVec<def_id> {
|
||||
let results = @dvec();
|
||||
let results = @DVec();
|
||||
for items.each |item| {
|
||||
match item.node {
|
||||
item_class(*) | item_enum(*) | item_trait(*) => {
|
||||
|
|
|
@ -262,7 +262,7 @@ import driver::session::session;
|
|||
import util::common::{indent, indenter};
|
||||
import ast::{unsafe_fn, impure_fn, pure_fn, extern_fn};
|
||||
import ast::{m_const, m_imm, m_mutbl};
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import region_var_bindings::{RegionVarBindings};
|
||||
import ast_util::dummy_sp;
|
||||
|
||||
|
@ -376,7 +376,7 @@ fn new_infer_ctxt(tcx: ty::ctxt) -> infer_ctxt {
|
|||
ty_var_counter: @mut 0u,
|
||||
ty_var_integral_counter: @mut 0u,
|
||||
region_var_counter: @mut 0u,
|
||||
borrowings: dvec()})}
|
||||
borrowings: DVec()})}
|
||||
|
||||
fn mk_sub(cx: infer_ctxt, a_is_expected: bool, span: span) -> Sub {
|
||||
Sub(combine_fields {infcx: cx, a_is_expected: a_is_expected, span: span})
|
||||
|
|
|
@ -305,7 +305,7 @@ because `&x` was created alone, but is relatable to `&A`.
|
|||
#[warn(deprecated_mode)];
|
||||
#[warn(deprecated_pattern)];
|
||||
|
||||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
import result::Result;
|
||||
import result::{Ok, Err};
|
||||
import std::map::{hashmap, uint_hash};
|
||||
|
@ -365,12 +365,12 @@ struct RegionVarBindings {
|
|||
fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
|
||||
RegionVarBindings {
|
||||
tcx: tcx,
|
||||
var_spans: dvec(),
|
||||
var_spans: DVec(),
|
||||
values: empty_cell(),
|
||||
constraints: hashmap(hash_constraint, sys::shape_eq),
|
||||
lubs: CombineMap(),
|
||||
glbs: CombineMap(),
|
||||
undo_log: dvec()
|
||||
undo_log: DVec()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ fn exec<T:send>(
|
|||
srv: srv,
|
||||
+f: fn~(ctxt: ctxt) -> T
|
||||
) -> T {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let msg = handle_request(fn~(move f, ctxt: ctxt) {
|
||||
comm::send(ch, f(ctxt))
|
||||
});
|
||||
|
|
|
@ -109,15 +109,15 @@ fn pandoc_writer(
|
|||
os::close(pipe_err.out);
|
||||
os::close(pipe_in.out);
|
||||
|
||||
let stdout_po = comm::port();
|
||||
let stdout_ch = comm::chan(stdout_po);
|
||||
let stdout_po = comm::Port();
|
||||
let stdout_ch = comm::Chan(stdout_po);
|
||||
do task::spawn_sched(task::SingleThreaded) {
|
||||
comm::send(stdout_ch, readclose(pipe_out.in));
|
||||
}
|
||||
let stdout = comm::recv(stdout_po);
|
||||
|
||||
let stderr_po = comm::port();
|
||||
let stderr_ch = comm::chan(stderr_po);
|
||||
let stderr_po = comm::Port();
|
||||
let stderr_ch = comm::Chan(stderr_po);
|
||||
do task::spawn_sched(task::SingleThreaded) {
|
||||
comm::send(stderr_ch, readclose(pipe_err.in));
|
||||
}
|
||||
|
@ -267,11 +267,11 @@ fn write_file(path: &Path, s: ~str) {
|
|||
|
||||
fn future_writer_factory(
|
||||
) -> (writer_factory, comm::Port<(doc::page, ~str)>) {
|
||||
let markdown_po = comm::port();
|
||||
let markdown_ch = comm::chan(markdown_po);
|
||||
let markdown_po = comm::Port();
|
||||
let markdown_ch = comm::Chan(markdown_po);
|
||||
let writer_factory = fn~(page: doc::page) -> writer {
|
||||
let writer_po = comm::port();
|
||||
let writer_ch = comm::chan(writer_po);
|
||||
let writer_po = comm::Port();
|
||||
let writer_ch = comm::Chan(writer_po);
|
||||
do task::spawn {
|
||||
let (writer, future) = future_writer();
|
||||
comm::send(writer_ch, writer);
|
||||
|
@ -285,8 +285,8 @@ fn future_writer_factory(
|
|||
}
|
||||
|
||||
fn future_writer() -> (writer, future::Future<~str>) {
|
||||
let port = comm::port();
|
||||
let chan = comm::chan(port);
|
||||
let port = comm::Port();
|
||||
let chan = comm::Chan(port);
|
||||
let writer = fn~(+instr: writeinstr) {
|
||||
comm::send(chan, copy instr);
|
||||
};
|
||||
|
|
|
@ -3,8 +3,8 @@ export foo;
|
|||
import comm::*;
|
||||
|
||||
fn foo<T: send copy>(x: T) -> Port<T> {
|
||||
let p = port();
|
||||
let c = chan(p);
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
do task::spawn() |copy c, copy x| {
|
||||
c.send(x);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import dvec::{DVec, dvec};
|
||||
import dvec::DVec;
|
||||
|
||||
type entry<A,B> = {key: A, value: B};
|
||||
type alist<A,B> = { eq_fn: fn@(A,A) -> bool, data: DVec<entry<A,B>> };
|
||||
|
@ -18,12 +18,12 @@ fn alist_get<A: copy, B: copy>(lst: alist<A,B>, k: A) -> B {
|
|||
#[inline]
|
||||
fn new_int_alist<B: copy>() -> alist<int, B> {
|
||||
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
|
||||
return {eq_fn: eq_int, data: dvec()};
|
||||
return {eq_fn: eq_int, data: DVec()};
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn new_int_alist_2<B: copy>() -> alist<int, B> {
|
||||
#[inline]
|
||||
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
|
||||
return {eq_fn: eq_int, data: dvec()};
|
||||
return {eq_fn: eq_int, data: DVec()};
|
||||
}
|
|
@ -168,10 +168,10 @@ fn main(args: ~[~str]) {
|
|||
let rng = rand::seeded_rng(copy seed);
|
||||
let mut results = empty_results();
|
||||
int_benchmarks::<Managed<LinearMap<uint, uint>>>(
|
||||
|| Managed(linear_map(uint::hash, uint::eq)),
|
||||
|| Managed(LinearMap(uint::hash, uint::eq)),
|
||||
rng, num_keys, &mut results);
|
||||
str_benchmarks::<Managed<LinearMap<~str, uint>>>(
|
||||
|| Managed(linear_map(str::hash, str::eq)),
|
||||
|| Managed(LinearMap(str::hash, str::eq)),
|
||||
rng, num_keys, &mut results);
|
||||
write_results("libstd::map::hashmap", &results);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ fn read_line() {
|
|||
}
|
||||
|
||||
fn str_set() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
|
||||
let s = map::hashmap(str::hash, str::eq);
|
||||
|
||||
|
@ -82,7 +82,7 @@ fn str_set() {
|
|||
}
|
||||
|
||||
fn vec_plus() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
|
||||
let mut v = ~[];
|
||||
let mut i = 0;
|
||||
|
@ -99,7 +99,7 @@ fn vec_plus() {
|
|||
}
|
||||
|
||||
fn vec_append() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
|
||||
let mut v = ~[];
|
||||
let mut i = 0;
|
||||
|
@ -116,7 +116,7 @@ fn vec_append() {
|
|||
}
|
||||
|
||||
fn vec_push_all() {
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
|
||||
let mut v = ~[];
|
||||
for uint::range(0, 1500) |i| {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// A raw test of vector appending performance.
|
||||
|
||||
use std;
|
||||
import dvec::dvec;
|
||||
import dvec::DVec;
|
||||
import io::WriterUtil;
|
||||
|
||||
fn collect_raw(num: uint) -> ~[uint] {
|
||||
|
@ -13,7 +13,7 @@ fn collect_raw(num: uint) -> ~[uint] {
|
|||
}
|
||||
|
||||
fn collect_dvec(num: uint) -> ~[mut uint] {
|
||||
let result = dvec();
|
||||
let result = DVec();
|
||||
for uint::range(0u, num) |i| {
|
||||
result.push(i);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
|
|||
|
||||
fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] {
|
||||
let keys = map::hashmap::<node_id, ()>(node_hash, sys::shape_eq);
|
||||
let r = rand::rng();
|
||||
let r = rand::Rng();
|
||||
|
||||
while keys.size() < n {
|
||||
let k = r.gen_uint_range(0u, graph.len());
|
||||
|
|
|
@ -33,8 +33,8 @@ fn main(args: ~[~str]) {
|
|||
let num_tasks = option::get(uint::from_str(args[1]));
|
||||
let msg_per_task = option::get(uint::from_str(args[2]));
|
||||
|
||||
let num_port = port();
|
||||
let mut num_chan = chan(num_port);
|
||||
let num_port = Port();
|
||||
let mut num_chan = Chan(num_port);
|
||||
|
||||
let start = time::precise_time_s();
|
||||
|
||||
|
@ -42,12 +42,12 @@ fn main(args: ~[~str]) {
|
|||
let mut futures = ~[];
|
||||
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
let get_chan = port();
|
||||
let get_chan_chan = chan(get_chan);
|
||||
let get_chan = Port();
|
||||
let get_chan_chan = Chan(get_chan);
|
||||
|
||||
futures += ~[do future::spawn |copy num_chan, move get_chan_chan| {
|
||||
let p = port();
|
||||
get_chan_chan.send(chan(p));
|
||||
let p = Port();
|
||||
get_chan_chan.send(Chan(p));
|
||||
thread_ring(i, msg_per_task, num_chan, p)
|
||||
}];
|
||||
|
||||
|
|
|
@ -122,12 +122,12 @@ fn creature(
|
|||
|
||||
fn rendezvous(nn: uint, set: ~[color]) {
|
||||
// these ports will allow us to hear from the creatures
|
||||
let from_creatures: comm::Port<creature_info> = comm::port();
|
||||
let from_creatures_log: comm::Port<~str> = comm::port();
|
||||
let from_creatures: comm::Port<creature_info> = comm::Port();
|
||||
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>>] =
|
||||
|
|
|
@ -45,7 +45,7 @@ fn select_random(r: u32, genelist: ~[aminoacids]) -> char {
|
|||
|
||||
fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[aminoacids], n: int) {
|
||||
wr.write_line(~">" + id + ~" " + desc);
|
||||
let rng = @{mut last: rand::rng().next()};
|
||||
let rng = @{mut last: rand::Rng().next()};
|
||||
let mut op: ~str = ~"";
|
||||
for uint::range(0u, n as uint) |_i| {
|
||||
str::push_char(op, select_random(myrandom_next(rng, 100u32),
|
||||
|
|
|
@ -138,8 +138,8 @@ fn main(args: ~[~str]) {
|
|||
|
||||
// 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 from_child = vec::map (sizes, |_sz| comm::Port() );
|
||||
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(from_child[ii]) );
|
||||
let to_child = vec::mapi(sizes, fn@(ii: uint, sz: uint) -> comm::Chan<~[u8]> {
|
||||
return do task::spawn_listener |from_parent| {
|
||||
make_sequence_processor(sz, from_parent, to_parent[ii]);
|
||||
|
|
|
@ -100,8 +100,8 @@ 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 p: comm::Port<line> = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
comm::send(writech, ch);
|
||||
let cout: io::Writer = match path {
|
||||
~"" => {
|
||||
|
@ -168,8 +168,8 @@ fn main(args: ~[~str]) {
|
|||
let size = if vec::len(args) < 2_u { 80_u }
|
||||
else { uint::from_str(args[1]).get() };
|
||||
|
||||
let writep = comm::port();
|
||||
let writech = comm::chan(writep);
|
||||
let writep = comm::Port();
|
||||
let writech = comm::Chan(writep);
|
||||
do task::spawn {
|
||||
writer(path, writech, size);
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@ const n_threads: int = 503;
|
|||
fn start(+token: int) {
|
||||
import iter::*;
|
||||
|
||||
let p = comm::port();
|
||||
let mut ch = comm::chan(p);
|
||||
let p = comm::Port();
|
||||
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| {
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
// Creates in the background 'num_tasks' tasks, all blocked forever.
|
||||
// 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 po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
|
||||
for num_tasks.times {
|
||||
do task::spawn { // linked
|
||||
comm::send(ch, ());
|
||||
comm::recv(comm::port::<()>()); // block forever
|
||||
comm::recv(comm::Port::<()>()); // block forever
|
||||
}
|
||||
}
|
||||
#error["Grandchild group getting started"];
|
||||
|
|
|
@ -7,8 +7,8 @@ enum msg {
|
|||
}
|
||||
|
||||
fn calc(children: uint, parent_ch: comm::Chan<msg>) {
|
||||
let port = comm::port();
|
||||
let chan = comm::chan(port);
|
||||
let port = comm::Port();
|
||||
let chan = comm::Chan(port);
|
||||
let mut child_chs = ~[];
|
||||
let mut sum = 0;
|
||||
|
||||
|
@ -58,8 +58,8 @@ fn main(args: ~[~str]) {
|
|||
};
|
||||
|
||||
let children = uint::from_str(args[1]).get();
|
||||
let port = comm::port();
|
||||
let chan = comm::chan(port);
|
||||
let port = comm::Port();
|
||||
let chan = comm::Chan(port);
|
||||
do task::spawn {
|
||||
calc(children, chan);
|
||||
};
|
||||
|
|
|
@ -28,9 +28,7 @@ import u64;
|
|||
import task;
|
||||
import comm;
|
||||
import comm::Chan;
|
||||
import comm::chan;
|
||||
import comm::Port;
|
||||
import comm::port;
|
||||
import comm::recv;
|
||||
import comm::send;
|
||||
|
||||
|
@ -62,8 +60,8 @@ impl ~str: hash_key {
|
|||
// These used to be in task, but they disappeard.
|
||||
type joinable_task = Port<()>;
|
||||
fn spawn_joinable(+f: fn~()) -> joinable_task {
|
||||
let p = port();
|
||||
let c = chan(p);
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
do task::spawn() |move f| {
|
||||
f();
|
||||
c.send(());
|
||||
|
@ -214,9 +212,9 @@ mod map_reduce {
|
|||
key: K,
|
||||
out: Chan<Chan<reduce_proto<V>>>)
|
||||
{
|
||||
let p = port();
|
||||
let p = Port();
|
||||
|
||||
send(out, chan(p));
|
||||
send(out, Chan(p));
|
||||
|
||||
let mut ref_count = 0;
|
||||
let mut is_done = false;
|
||||
|
@ -277,8 +275,8 @@ mod map_reduce {
|
|||
}
|
||||
None => {
|
||||
// log(error, "creating new reducer for " + k);
|
||||
let p = port();
|
||||
let ch = chan(p);
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let r = reduce, kk = k;
|
||||
vec::push(tasks,
|
||||
spawn_joinable(|| reduce_task(r, kk, ch) ));
|
||||
|
@ -355,7 +353,7 @@ struct random_word_reader: word_reader {
|
|||
let rng: rand::Rng;
|
||||
new(count: uint) {
|
||||
self.remaining = count;
|
||||
self.rng = rand::rng();
|
||||
self.rng = rand::Rng();
|
||||
}
|
||||
|
||||
fn read_word() -> Option<~str> {
|
||||
|
|
|
@ -5,7 +5,7 @@ fn main() {
|
|||
drop {}
|
||||
}
|
||||
|
||||
let x = ~mut Some(foo(comm::port()));
|
||||
let x = ~mut Some(foo(comm::Port()));
|
||||
|
||||
do task::spawn |move x| { //~ ERROR not a sendable value
|
||||
let mut y = None;
|
||||
|
|
|
@ -9,7 +9,7 @@ struct foo {
|
|||
|
||||
fn main() {
|
||||
let cat = ~"kitty";
|
||||
let po = comm::port(); //~ ERROR missing `send`
|
||||
let ch = comm::chan(po); //~ ERROR missing `send`
|
||||
let po = comm::Port(); //~ ERROR missing `send`
|
||||
let ch = comm::Chan(po); //~ ERROR missing `send`
|
||||
comm::send(ch, foo(42, @cat)); //~ ERROR missing `send`
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
// error-pattern:1 == 2
|
||||
use std;
|
||||
import task;
|
||||
import comm::port;
|
||||
import comm::Port;
|
||||
import comm::recv;
|
||||
|
||||
fn child() { assert (1 == 2); }
|
||||
|
||||
fn main() {
|
||||
let p = port::<int>();
|
||||
let p = Port::<int>();
|
||||
task::spawn(|| child() );
|
||||
let x = recv(p);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
// error-pattern:fail
|
||||
use std;
|
||||
import task;
|
||||
import comm::chan;
|
||||
import comm::port;
|
||||
import comm::Chan;
|
||||
import comm::Port;
|
||||
import comm::recv;
|
||||
|
||||
fn child() { fail; }
|
||||
|
||||
fn main() {
|
||||
let p = port::<int>();
|
||||
let p = Port::<int>();
|
||||
task::spawn(|| child() );
|
||||
task::yield();
|
||||
}
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
// error-pattern:fail
|
||||
use std;
|
||||
import task;
|
||||
import comm::port;
|
||||
import comm::Port;
|
||||
import comm::recv;
|
||||
|
||||
fn grandchild() { fail ~"grandchild dies"; }
|
||||
|
||||
fn child() {
|
||||
let p = port::<int>();
|
||||
let p = Port::<int>();
|
||||
task::spawn(|| grandchild() );
|
||||
let x = recv(p);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let p = port::<int>();
|
||||
let p = Port::<int>();
|
||||
task::spawn(|| child() );
|
||||
let x = recv(p);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// error-pattern:1 == 2
|
||||
use std;
|
||||
import task;
|
||||
import comm::chan;
|
||||
import comm::port;
|
||||
import comm::Chan;
|
||||
import comm::Port;
|
||||
import comm::recv;
|
||||
|
||||
fn child() { assert (1 == 2); }
|
||||
|
||||
fn parent() {
|
||||
let p = port::<int>();
|
||||
let p = Port::<int>();
|
||||
task::spawn(|| child() );
|
||||
let x = recv(p);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ fn parent() {
|
|||
// This task is not linked to the failure chain, but since the other
|
||||
// tasks are going to fail the kernel, this one will fail too
|
||||
fn sleeper() {
|
||||
let p = port::<int>();
|
||||
let p = Port::<int>();
|
||||
let x = recv(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
// error-pattern:meep
|
||||
use std;
|
||||
import comm::Chan;
|
||||
import comm::chan;
|
||||
import comm::port;
|
||||
import comm::Port;
|
||||
import comm::send;
|
||||
import comm::recv;
|
||||
|
||||
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));
|
||||
let p = Port::<T>();
|
||||
send(oc, Chan(p));
|
||||
|
||||
let x = recv(p);
|
||||
send(c, x);
|
||||
|
|
|
@ -11,7 +11,7 @@ fn goodfail() {
|
|||
|
||||
fn main() {
|
||||
task::spawn(|| goodfail() );
|
||||
let po = comm::port();
|
||||
let po = comm::Port();
|
||||
// We shouldn't be able to get past this recv since there's no
|
||||
// message available
|
||||
let i: int = comm::recv(po);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn main() {
|
||||
let x = dvec::dvec();
|
||||
let x = dvec::DVec();
|
||||
x.push(1);
|
||||
io::println(fmt!("%d", x[0]));
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) );
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) );
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -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'));
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use std;
|
||||
|
||||
import comm::chan;
|
||||
import comm::Chan;
|
||||
import comm::send;
|
||||
|
||||
fn main() { test05(); }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std;
|
||||
|
||||
import comm::chan;
|
||||
import comm::Chan;
|
||||
import comm::send;
|
||||
|
||||
fn main() { test05(); }
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue