De-mode comm::Chan
This commit is contained in:
parent
777baeb298
commit
fe12da0864
@ -2952,7 +2952,7 @@ An example of a `spawn` call:
|
||||
|
||||
~~~~
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
|
||||
do task::spawn {
|
||||
// let task run, do other things
|
||||
@ -2974,7 +2974,7 @@ An example of a send:
|
||||
|
||||
~~~~
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
comm::send(ch, ~"hello, world");
|
||||
~~~~
|
||||
|
||||
@ -2990,7 +2990,7 @@ An example of a *receive*:
|
||||
|
||||
~~~~~~~~
|
||||
# let po = comm::Port();
|
||||
# let ch = comm::Chan(po);
|
||||
# let ch = comm::Chan(&po);
|
||||
# comm::send(ch, ~"");
|
||||
let s = comm::recv(po);
|
||||
~~~~~~~~
|
||||
|
@ -32,8 +32,8 @@ will once again be the preferred module for intertask communication.
|
||||
|
||||
*/
|
||||
|
||||
// NB: transitionary, de-mode-ing
|
||||
// tjc: re-forbid deprecated modes after snapshot
|
||||
// NB: transitionary, de-mode-ing.
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
use either::Either;
|
||||
@ -74,7 +74,7 @@ pub fn Port<T: Send>() -> Port<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(move v) }
|
||||
fn recv() -> T { recv(self) }
|
||||
fn peek() -> bool { peek(self) }
|
||||
@ -166,7 +166,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.
|
||||
*/
|
||||
pub fn Chan<T: Send>(&&p: Port<T>) -> Chan<T> {
|
||||
pub fn Chan<T: Send>(p: &Port<T>) -> Chan<T> {
|
||||
Chan_(rustrt::get_port_id((**p).po))
|
||||
}
|
||||
|
||||
@ -304,19 +304,19 @@ 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 c = Chan(&p);
|
||||
send(c, 22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_recv_fn() {
|
||||
let p = Port::<int>();
|
||||
let c = Chan::<int>(p);
|
||||
let c = Chan::<int>(&p);
|
||||
send(c, 42);
|
||||
assert (recv(p) == 42);
|
||||
}
|
||||
@ -324,7 +324,7 @@ fn send_recv_fn() {
|
||||
#[test]
|
||||
fn send_recv_fn_infer() {
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
let c = Chan(&p);
|
||||
send(c, 42);
|
||||
assert (recv(p) == 42);
|
||||
}
|
||||
@ -332,23 +332,23 @@ fn send_recv_fn_infer() {
|
||||
#[test]
|
||||
fn chan_chan_infer() {
|
||||
let p = Port(), p2 = Port::<int>();
|
||||
let c = Chan(p);
|
||||
send(c, Chan(p2));
|
||||
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 c = Chan(&p);
|
||||
send(c, Chan(&p2));
|
||||
recv(p);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_peek() {
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
let ch = Chan(&po);
|
||||
assert !peek(po);
|
||||
send(ch, ());
|
||||
assert peek(po);
|
||||
@ -360,8 +360,8 @@ fn test_peek() {
|
||||
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 ch_a = Chan(&po_a);
|
||||
let ch_b = Chan(&po_b);
|
||||
|
||||
send(ch_a, ~"a");
|
||||
|
||||
@ -376,8 +376,8 @@ fn test_select2_available() {
|
||||
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 ch_a = Chan(&po_a);
|
||||
let ch_b = Chan(&po_b);
|
||||
|
||||
for iter::repeat(10) {
|
||||
do task::spawn {
|
||||
@ -400,8 +400,8 @@ fn test_select2_rendezvous() {
|
||||
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 ch_a = Chan(&po_a);
|
||||
let ch_b = Chan(&po_b);
|
||||
|
||||
let msgs = 100;
|
||||
let times = 4u;
|
||||
@ -436,7 +436,7 @@ fn test_select2_stress() {
|
||||
#[test]
|
||||
fn test_recv_chan() {
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
let ch = Chan(&po);
|
||||
send(ch, ~"flower");
|
||||
assert recv_chan(ch) == ~"flower";
|
||||
}
|
||||
@ -445,7 +445,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);
|
||||
}
|
||||
@ -454,7 +454,7 @@ fn test_recv_chan_dead() {
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_recv_chan_wrong_task() {
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
let ch = Chan(&po);
|
||||
send(ch, ~"flower");
|
||||
assert result::is_err(&task::try(||
|
||||
recv_chan(ch)
|
||||
|
@ -326,10 +326,10 @@ impl<T: Eq> Option<T> : Eq {
|
||||
#[test]
|
||||
fn test_unwrap_ptr() {
|
||||
let x = ~0;
|
||||
let addr_x = ptr::p2::addr_of(&(*x));
|
||||
let addr_x = ptr::addr_of(&(*x));
|
||||
let opt = Some(x);
|
||||
let y = unwrap(opt);
|
||||
let addr_y = ptr::p2::addr_of(&(*y));
|
||||
let addr_y = ptr::addr_of(&(*y));
|
||||
assert addr_x == addr_y;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ mod global_env {
|
||||
let env_ch = get_global_env_chan();
|
||||
let po = comm::Port();
|
||||
comm::send(env_ch, MsgGetEnv(str::from_slice(n),
|
||||
comm::Chan(po)));
|
||||
comm::Chan(&po)));
|
||||
comm::recv(po)
|
||||
}
|
||||
|
||||
@ -141,14 +141,14 @@ mod global_env {
|
||||
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)
|
||||
}
|
||||
|
||||
pub fn env() -> ~[(~str,~str)] {
|
||||
let env_ch = get_global_env_chan();
|
||||
let po = comm::Port();
|
||||
comm::send(env_ch, MsgEnv(comm::Chan(po)));
|
||||
comm::send(env_ch, MsgEnv(comm::Chan(&po)));
|
||||
comm::recv(po)
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ pub unsafe fn chan_from_global_ptr<T: Send>(
|
||||
let (setup_po, setup_ch) = do task_fn().spawn_conversation
|
||||
|move f, setup_po, setup_ch| {
|
||||
let po = comm::Port::<T>();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
comm::send(setup_ch, ch);
|
||||
|
||||
// Wait to hear if we are the official instance of
|
||||
@ -109,7 +109,7 @@ pub fn test_from_global_chan1() {
|
||||
|
||||
// The global channel
|
||||
let globchan = 0;
|
||||
let globchanp = ptr::p2::addr_of(&globchan);
|
||||
let globchanp = ptr::addr_of(&globchan);
|
||||
|
||||
// Create the global channel, attached to a new task
|
||||
let ch = unsafe {
|
||||
@ -122,7 +122,7 @@ pub fn test_from_global_chan1() {
|
||||
};
|
||||
// Talk to it
|
||||
let po = comm::Port();
|
||||
comm::send(ch, comm::Chan(po));
|
||||
comm::send(ch, comm::Chan(&po));
|
||||
assert comm::recv(po) == true;
|
||||
|
||||
// This one just reuses the previous channel
|
||||
@ -135,7 +135,7 @@ pub fn test_from_global_chan1() {
|
||||
|
||||
// Talk to the original global task
|
||||
let po = comm::Port();
|
||||
comm::send(ch, comm::Chan(po));
|
||||
comm::send(ch, comm::Chan(&po));
|
||||
assert comm::recv(po) == true;
|
||||
}
|
||||
|
||||
@ -145,10 +145,10 @@ pub fn test_from_global_chan2() {
|
||||
for iter::repeat(100) {
|
||||
// The global channel
|
||||
let globchan = 0;
|
||||
let globchanp = ptr::p2::addr_of(&globchan);
|
||||
let globchanp = ptr::addr_of(&globchan);
|
||||
|
||||
let resultpo = comm::Port();
|
||||
let resultch = comm::Chan(resultpo);
|
||||
let resultch = comm::Chan(&resultpo);
|
||||
|
||||
// Spawn a bunch of tasks that all want to compete to
|
||||
// create the global channel
|
||||
@ -165,7 +165,7 @@ pub fn test_from_global_chan2() {
|
||||
}
|
||||
};
|
||||
let po = comm::Port();
|
||||
comm::send(ch, comm::Chan(po));
|
||||
comm::send(ch, comm::Chan(&po));
|
||||
// We are The winner if our version of the
|
||||
// task was installed
|
||||
let winner = comm::recv(po);
|
||||
@ -203,7 +203,7 @@ pub fn test_from_global_chan2() {
|
||||
*/
|
||||
pub unsafe fn weaken_task(f: fn(comm::Port<()>)) {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
unsafe {
|
||||
rustrt::rust_task_weaken(cast::reinterpret_cast(&ch));
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ pub fn program_output(prog: &str, args: &[~str]) ->
|
||||
// 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 ch = comm::Chan(&p);
|
||||
do task::spawn_sched(task::SingleThreaded) {
|
||||
let errput = readclose(pipe_err.in);
|
||||
comm::send(ch, (2, move errput));
|
||||
|
@ -479,10 +479,10 @@ impl TaskBuilder {
|
||||
*/
|
||||
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_ch = comm::Chan(&setup_po);
|
||||
do self.spawn |move f| {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
comm::send(setup_ch, ch);
|
||||
f(move po);
|
||||
}
|
||||
@ -496,7 +496,7 @@ impl TaskBuilder {
|
||||
(+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 to_parent = comm::Chan(&from_child);
|
||||
let to_child = do self.spawn_listener |move f, from_parent| {
|
||||
f(from_parent, to_parent)
|
||||
};
|
||||
@ -518,7 +518,7 @@ impl TaskBuilder {
|
||||
*/
|
||||
fn try<T: Send>(+f: fn~() -> T) -> Result<T,()> {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
let mut result = None;
|
||||
|
||||
let fr_task_builder = self.future_result(|+r| {
|
||||
@ -772,7 +772,7 @@ 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 ch = comm::Chan(&po);
|
||||
do spawn_unlinked {
|
||||
do spawn_unlinked {
|
||||
// Give middle task a chance to fail-but-not-kill-us.
|
||||
@ -802,7 +802,7 @@ 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 _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()).
|
||||
@ -845,7 +845,7 @@ 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 _ch = comm::Chan(&po);
|
||||
// Default options are to spawn linked & unsupervised.
|
||||
do spawn { fail; }
|
||||
comm::recv(po); // We should get punted awake
|
||||
@ -917,7 +917,7 @@ fn test_spawn_linked_sup_propagate_sibling() {
|
||||
#[test]
|
||||
fn test_run_basic() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
do task().spawn {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
@ -927,7 +927,7 @@ fn test_run_basic() {
|
||||
#[test]
|
||||
fn test_add_wrapper() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
let b0 = task();
|
||||
let b1 = do b0.add_wrapper |body| {
|
||||
fn~() {
|
||||
@ -961,7 +961,7 @@ fn test_back_to_the_future_result() {
|
||||
#[test]
|
||||
fn test_spawn_listiner_bidi() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
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'.
|
||||
@ -1017,7 +1017,7 @@ fn test_spawn_sched_no_threads() {
|
||||
#[test]
|
||||
fn test_spawn_sched() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
|
||||
fn f(i: int, ch: comm::Chan<()>) {
|
||||
let parent_sched_id = rt::rust_get_sched_id();
|
||||
@ -1041,7 +1041,7 @@ fn test_spawn_sched() {
|
||||
#[test]
|
||||
fn test_spawn_sched_childs_on_same_sched() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
|
||||
do spawn_sched(SingleThreaded) {
|
||||
let parent_sched_id = rt::rust_get_sched_id();
|
||||
@ -1075,9 +1075,9 @@ fn test_spawn_sched_blocking() {
|
||||
for iter::repeat(20u) {
|
||||
|
||||
let start_po = comm::Port();
|
||||
let start_ch = comm::Chan(start_po);
|
||||
let start_ch = comm::Chan(&start_po);
|
||||
let fin_po = comm::Port();
|
||||
let fin_ch = comm::Chan(fin_po);
|
||||
let fin_ch = comm::Chan(&fin_po);
|
||||
|
||||
let lock = testrt::rust_dbg_lock_create();
|
||||
|
||||
@ -1105,12 +1105,12 @@ fn test_spawn_sched_blocking() {
|
||||
}
|
||||
|
||||
let setup_po = comm::Port();
|
||||
let setup_ch = comm::Chan(setup_po);
|
||||
let setup_ch = comm::Chan(&setup_po);
|
||||
let parent_po = comm::Port();
|
||||
let parent_ch = comm::Chan(parent_po);
|
||||
let parent_ch = comm::Chan(&parent_po);
|
||||
do spawn {
|
||||
let child_po = comm::Port();
|
||||
comm::send(setup_ch, comm::Chan(child_po));
|
||||
comm::send(setup_ch, comm::Chan(&child_po));
|
||||
pingpong(child_po, parent_ch);
|
||||
};
|
||||
|
||||
@ -1128,13 +1128,13 @@ fn test_spawn_sched_blocking() {
|
||||
#[cfg(test)]
|
||||
fn avoid_copying_the_body(spawnfn: fn(+v: fn~())) {
|
||||
let p = comm::Port::<uint>();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
|
||||
let x = ~1;
|
||||
let x_in_parent = ptr::p2::addr_of(&(*x)) as uint;
|
||||
let x_in_parent = ptr::addr_of(&(*x)) as uint;
|
||||
|
||||
do spawnfn {
|
||||
let x_in_child = ptr::p2::addr_of(&(*x)) as uint;
|
||||
let x_in_child = ptr::addr_of(&(*x)) as uint;
|
||||
comm::send(ch, x_in_child);
|
||||
}
|
||||
|
||||
@ -1195,7 +1195,7 @@ fn test_avoid_copying_the_body_unlinked() {
|
||||
#[test]
|
||||
fn test_platform_thread() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
do task().sched_mode(PlatformThread).spawn {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ pub fn spawn_raw(opts: TaskOpts, +f: fn~()) {
|
||||
#[test]
|
||||
fn test_spawn_raw_simple() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
do spawn_raw(default_task_opts()) {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
||||
let result_po = core::comm::Port::<ConnAttempt>();
|
||||
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], TcpErrData>>();
|
||||
@ -130,7 +130,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
|
||||
*(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(),
|
||||
@ -471,7 +471,7 @@ pub fn accept(new_conn: TcpNewConnection)
|
||||
*(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(),
|
||||
@ -482,7 +482,7 @@ pub fn accept(new_conn: TcpNewConnection)
|
||||
(*client_socket_data_ptr).stream_handle_ptr;
|
||||
|
||||
let result_po = core::comm::Port::<Option<TcpErrData>>();
|
||||
let result_ch = core::comm::Chan(result_po);
|
||||
let result_ch = core::comm::Chan(&result_po);
|
||||
|
||||
// UNSAFE LIBUV INTERACTION BEGIN
|
||||
// .. normally this happens within the context of
|
||||
@ -580,12 +580,12 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
|
||||
-> result::Result<(), TcpListenErrData> unsafe {
|
||||
let stream_closed_po = core::comm::Port::<()>();
|
||||
let kill_po = core::comm::Port::<Option<TcpErrData>>();
|
||||
let kill_ch = core::comm::Chan(kill_po);
|
||||
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: move on_connect_cb,
|
||||
iotask: iotask,
|
||||
@ -832,7 +832,7 @@ impl TcpSocketBuf: io::Writer {
|
||||
|
||||
fn tear_down_socket_data(socket_data: @TcpSocketData) unsafe {
|
||||
let closed_po = core::comm::Port::<()>();
|
||||
let closed_ch = core::comm::Chan(closed_po);
|
||||
let closed_ch = core::comm::Chan(&closed_po);
|
||||
let close_data = {
|
||||
closed_ch: closed_ch
|
||||
};
|
||||
@ -895,7 +895,7 @@ fn read_stop_common_impl(socket_data: *TcpSocketData) ->
|
||||
result::Result<(), TcpErrData> unsafe {
|
||||
let stream_handle_ptr = (*socket_data).stream_handle_ptr;
|
||||
let stop_po = core::comm::Port::<Option<TcpErrData>>();
|
||||
let stop_ch = core::comm::Chan(stop_po);
|
||||
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) {
|
||||
@ -922,7 +922,7 @@ fn read_start_common_impl(socket_data: *TcpSocketData)
|
||||
result::Result<~[u8], TcpErrData>>, TcpErrData> 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_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,7 +961,7 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData,
|
||||
let write_buf_vec_ptr = ptr::addr_of(&write_buf_vec);
|
||||
let result_po = core::comm::Port::<TcpWriteResult>();
|
||||
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 {
|
||||
@ -1277,10 +1277,10 @@ mod test {
|
||||
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_ch = core::comm::Chan(&server_result_po);
|
||||
|
||||
let cont_po = core::comm::Port::<()>();
|
||||
let cont_ch = core::comm::Chan(cont_po);
|
||||
let cont_ch = core::comm::Chan(&cont_po);
|
||||
// server
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
let actual_req = do comm::listen |server_ch| {
|
||||
@ -1343,10 +1343,10 @@ mod test {
|
||||
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_ch = core::comm::Chan(&server_result_po);
|
||||
|
||||
let cont_po = core::comm::Port::<()>();
|
||||
let cont_ch = core::comm::Chan(cont_po);
|
||||
let cont_ch = core::comm::Chan(&cont_po);
|
||||
// server
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
let actual_req = do comm::listen |server_ch| {
|
||||
|
@ -773,7 +773,7 @@ mod tests {
|
||||
let m = ~Mutex();
|
||||
let m2 = ~m.clone();
|
||||
let mut sharedstate = ~0;
|
||||
let ptr = ptr::p2::addr_of(&(*sharedstate));
|
||||
let ptr = ptr::addr_of(&(*sharedstate));
|
||||
do task::spawn {
|
||||
let sharedstate: &mut int =
|
||||
unsafe { cast::reinterpret_cast(&ptr) };
|
||||
@ -1045,7 +1045,7 @@ mod tests {
|
||||
let (c,p) = pipes::stream();
|
||||
let x2 = ~x.clone();
|
||||
let mut sharedstate = ~0;
|
||||
let ptr = ptr::p2::addr_of(&(*sharedstate));
|
||||
let ptr = ptr::addr_of(&(*sharedstate));
|
||||
do task::spawn {
|
||||
let sharedstate: &mut int =
|
||||
unsafe { cast::reinterpret_cast(&ptr) };
|
||||
|
@ -286,7 +286,7 @@ fn run_tests(opts: &TestOpts, tests: &[TestDesc],
|
||||
let mut done_idx = 0;
|
||||
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
let ch = core::comm::Chan(&p);
|
||||
|
||||
while done_idx < total {
|
||||
while wait_idx < concurrency && run_idx < total {
|
||||
@ -421,7 +421,7 @@ mod tests {
|
||||
should_fail: false
|
||||
};
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
let ch = core::comm::Chan(&p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res != TrOk;
|
||||
@ -437,7 +437,7 @@ mod tests {
|
||||
should_fail: false
|
||||
};
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
let ch = core::comm::Chan(&p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res == TrIgnored;
|
||||
@ -454,7 +454,7 @@ mod tests {
|
||||
should_fail: true
|
||||
};
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
let ch = core::comm::Chan(&p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res == TrOk;
|
||||
@ -470,7 +470,7 @@ mod tests {
|
||||
should_fail: true
|
||||
};
|
||||
let p = core::comm::Port();
|
||||
let ch = core::comm::Chan(p);
|
||||
let ch = core::comm::Chan(&p);
|
||||
run_test(desc, ch);
|
||||
let (_, res) = core::comm::recv(p);
|
||||
assert res == TrFailed;
|
||||
|
@ -27,7 +27,7 @@ pub 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_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);
|
||||
@ -74,7 +74,7 @@ pub fn delayed_send<T: Copy Send>(iotask: IoTask,
|
||||
*/
|
||||
pub fn sleep(iotask: IoTask, msecs: uint) {
|
||||
let exit_po = core::comm::Port::<()>();
|
||||
let exit_ch = core::comm::Chan(exit_po);
|
||||
let exit_ch = core::comm::Chan(&exit_po);
|
||||
delayed_send(iotask, msecs, exit_ch, ());
|
||||
core::comm::recv(exit_po);
|
||||
}
|
||||
@ -103,7 +103,7 @@ pub 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_ch = comm::Chan(&timeout_po);
|
||||
delayed_send(iotask, msecs, timeout_ch, ());
|
||||
// FIXME: This could be written clearer (#2618)
|
||||
either::either(
|
||||
@ -162,7 +162,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_gl_timer_sleep_stress2() {
|
||||
let po = core::comm::Port();
|
||||
let ch = core::comm::Chan(po);
|
||||
let ch = core::comm::Chan(&po);
|
||||
let hl_loop = uv::global_loop::get();
|
||||
|
||||
let repeat = 20u;
|
||||
@ -240,7 +240,7 @@ mod test {
|
||||
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 test_ch = core::comm::Chan(&test_po);
|
||||
|
||||
do task::spawn() {
|
||||
delayed_send(hl_loop, 50u, test_ch, expected);
|
||||
|
@ -133,12 +133,12 @@ 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_ch_ptr = ptr::p2::addr_of(&exit_ch);
|
||||
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));
|
||||
let timer_handle = ll::timer_t();
|
||||
let timer_ptr = ptr::p2::addr_of(&timer_handle);
|
||||
let timer_ptr = ptr::addr_of(&timer_handle);
|
||||
do iotask::interact(iotask) |loop_ptr| unsafe {
|
||||
log(debug, ~"user code inside interact loop!!!");
|
||||
let init_status = ll::timer_init(loop_ptr, timer_ptr);
|
||||
@ -166,7 +166,7 @@ mod 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_ch = comm::Chan(&exit_po);
|
||||
task::spawn_sched(task::ManualThreads(1u), || {
|
||||
impl_uv_hl_simple_timer(hl_loop);
|
||||
core::comm::send(exit_ch, ());
|
||||
@ -182,7 +182,7 @@ mod test {
|
||||
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_ch = core::comm::Chan(&exit_po);
|
||||
let cycles = 5000u;
|
||||
for iter::repeat(cycles) {
|
||||
task::spawn_sched(task::ManualThreads(1u), || {
|
||||
|
@ -184,7 +184,7 @@ mod test {
|
||||
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_ch = core::comm::Chan(&exit_po);
|
||||
let ah_data = {
|
||||
iotask: iotask,
|
||||
exit_ch: exit_ch
|
||||
@ -202,7 +202,7 @@ mod test {
|
||||
// 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_ch = comm::Chan(&iotask_port);
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
run_loop(iotask_ch);
|
||||
exit_ch.send(());
|
||||
@ -223,7 +223,7 @@ 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_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,
|
||||
@ -233,7 +233,7 @@ mod test {
|
||||
// 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_ch = core::comm::Chan(&work_exit_po);
|
||||
for iter::repeat(7u) {
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
impl_uv_iotask_async(iotask);
|
||||
|
@ -1466,12 +1466,12 @@ pub mod test {
|
||||
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 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 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_chan = core::comm::Chan::<bool>(&continue_port);
|
||||
let continue_chan_ptr = ptr::addr_of(&continue_chan);
|
||||
|
||||
do task::spawn_sched(task::ManualThreads(1)) {
|
||||
|
@ -229,7 +229,7 @@ bug and need to present an error.
|
||||
*/
|
||||
fn monitor(+f: fn~(diagnostic::emitter)) {
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
|
||||
match do task::try |move f| {
|
||||
|
||||
|
@ -93,7 +93,7 @@ fn exec<T:Send>(
|
||||
+f: fn~(ctxt: Ctxt) -> T
|
||||
) -> T {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
let msg = HandleRequest(fn~(move f, ctxt: Ctxt) {
|
||||
comm::send(ch, f(ctxt))
|
||||
});
|
||||
|
@ -109,14 +109,14 @@ fn pandoc_writer(
|
||||
os::close(pipe_in.out);
|
||||
|
||||
let stdout_po = comm::Port();
|
||||
let stdout_ch = comm::Chan(stdout_po);
|
||||
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_ch = comm::Chan(&stderr_po);
|
||||
do task::spawn_sched(task::SingleThreaded) {
|
||||
comm::send(stderr_ch, readclose(pipe_err.in));
|
||||
}
|
||||
@ -268,10 +268,10 @@ fn write_file(path: &Path, s: ~str) {
|
||||
fn future_writer_factory(
|
||||
) -> (WriterFactory, comm::Port<(doc::Page, ~str)>) {
|
||||
let markdown_po = comm::Port();
|
||||
let markdown_ch = comm::Chan(markdown_po);
|
||||
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_ch = comm::Chan(&writer_po);
|
||||
do task::spawn {
|
||||
let (writer, future) = future_writer();
|
||||
comm::send(writer_ch, writer);
|
||||
|
@ -6,7 +6,7 @@ use comm::*;
|
||||
|
||||
fn foo<T: Send Copy>(x: T) -> Port<T> {
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
let c = Chan(&p);
|
||||
do task::spawn() |copy c, copy x| {
|
||||
c.send(x);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ fn main() {
|
||||
let msg_per_task = uint::from_str(args[2]).get();
|
||||
|
||||
let num_port = Port();
|
||||
let mut num_chan = Chan(num_port);
|
||||
let mut num_chan = Chan(&num_port);
|
||||
|
||||
let start = time::precise_time_s();
|
||||
|
||||
@ -44,12 +44,12 @@ fn main() {
|
||||
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
let get_chan = Port();
|
||||
let get_chan_chan = Chan(get_chan);
|
||||
let get_chan_chan = Chan(&get_chan);
|
||||
|
||||
let new_future = do future::spawn
|
||||
|copy num_chan, move get_chan_chan| {
|
||||
let p = Port();
|
||||
get_chan_chan.send(Chan(p));
|
||||
get_chan_chan.send(Chan(&p));
|
||||
thread_ring(i, msg_per_task, num_chan, p)
|
||||
};
|
||||
futures.push(new_future);
|
||||
|
@ -126,8 +126,8 @@ fn rendezvous(nn: uint, set: ~[color]) {
|
||||
let from_creatures_log: comm::Port<~str> = comm::Port();
|
||||
|
||||
// these channels will be passed to the creatures so they can talk to us
|
||||
let to_rendezvous = comm::Chan(from_creatures);
|
||||
let to_rendezvous_log = comm::Chan(from_creatures_log);
|
||||
let to_rendezvous = comm::Chan(&from_creatures);
|
||||
let to_rendezvous_log = comm::Chan(&from_creatures_log);
|
||||
|
||||
// these channels will allow us to talk to each creature by 'name'/index
|
||||
let to_creature: ~[comm::Chan<Option<creature_info>>] =
|
||||
|
@ -142,7 +142,7 @@ fn main() {
|
||||
// initialize each sequence sorter
|
||||
let sizes = ~[1u,2u,3u,4u,6u,12u,18u];
|
||||
let from_child = vec::map (sizes, |_sz| comm::Port() );
|
||||
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(from_child[ii]) );
|
||||
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(&from_child[ii]) );
|
||||
let to_child = vec::mapi(sizes, |ii, sz| {
|
||||
let ii = ii;
|
||||
let sz = *sz;
|
||||
|
@ -103,7 +103,7 @@ impl devnull: io::Writer {
|
||||
fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
|
||||
{
|
||||
let p: comm::Port<line> = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
comm::send(writech, ch);
|
||||
let cout: io::Writer = match path {
|
||||
~"" => {
|
||||
@ -169,7 +169,7 @@ fn main() {
|
||||
else { uint::from_str(args[1]).get() };
|
||||
|
||||
let writep = comm::Port();
|
||||
let writech = comm::Chan(writep);
|
||||
let writech = comm::Chan(&writep);
|
||||
do task::spawn {
|
||||
writer(path, writech, size);
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ fn start(+token: int) {
|
||||
use iter::*;
|
||||
|
||||
let p = comm::Port();
|
||||
let mut ch = comm::Chan(p);
|
||||
let mut ch = comm::Chan(&p);
|
||||
for int::range(2, n_threads + 1) |i| {
|
||||
let id = n_threads + 2 - i;
|
||||
let to_child = do task::spawn_listener::<int> |p, copy ch| {
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Doesn't return until all such tasks are ready, but doesn't block forever itself.
|
||||
fn grandchild_group(num_tasks: uint) {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
|
||||
for num_tasks.times {
|
||||
do task::spawn { // linked
|
||||
|
@ -8,7 +8,7 @@ enum msg {
|
||||
|
||||
fn calc(children: uint, parent_ch: comm::Chan<msg>) {
|
||||
let port = comm::Port();
|
||||
let chan = comm::Chan(port);
|
||||
let chan = comm::Chan(&port);
|
||||
let mut child_chs = ~[];
|
||||
let mut sum = 0;
|
||||
|
||||
@ -60,7 +60,7 @@ fn main() {
|
||||
|
||||
let children = uint::from_str(args[1]).get();
|
||||
let port = comm::Port();
|
||||
let chan = comm::Chan(port);
|
||||
let chan = comm::Chan(&port);
|
||||
do task::spawn {
|
||||
calc(children, chan);
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ trait word_reader {
|
||||
type joinable_task = Port<()>;
|
||||
fn spawn_joinable(+f: fn~()) -> joinable_task {
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
let c = Chan(&p);
|
||||
do task::spawn() |move f| {
|
||||
f();
|
||||
c.send(());
|
||||
@ -206,7 +206,7 @@ mod map_reduce {
|
||||
{
|
||||
let p = Port();
|
||||
|
||||
send(out, Chan(p));
|
||||
send(out, Chan(&p));
|
||||
|
||||
let mut ref_count = 0;
|
||||
let mut is_done = false;
|
||||
@ -268,7 +268,7 @@ mod map_reduce {
|
||||
None => {
|
||||
// log(error, "creating new reducer for " + k);
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
let r = reduce, kk = k;
|
||||
tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) ));
|
||||
c = recv(p);
|
||||
|
@ -1,6 +1,6 @@
|
||||
enum bottom { }
|
||||
|
||||
fn main() {
|
||||
let x = ptr::p2::addr_of(&()) as *bottom;
|
||||
let x = ptr::addr_of(&()) as *bottom;
|
||||
match x { } //~ ERROR non-exhaustive patterns
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
let x : *~[int] = ptr::p2::addr_of(&~[1,2,3]);
|
||||
let x : *~[int] = ptr::addr_of(&~[1,2,3]);
|
||||
let y : *libc::c_void = x as *libc::c_void;
|
||||
unsafe {
|
||||
let _z = *y;
|
||||
|
@ -16,6 +16,6 @@ fn foo(i:int, j: @~str) -> foo {
|
||||
fn main() {
|
||||
let cat = ~"kitty";
|
||||
let po = comm::Port(); //~ ERROR missing `send`
|
||||
let ch = comm::Chan(po); //~ ERROR missing `send`
|
||||
let ch = comm::Chan(&po); //~ ERROR missing `send`
|
||||
comm::send(ch, foo(42, @cat)); //~ ERROR missing `send`
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ fn echo<T: Send>(c: Chan<T>, oc: Chan<Chan<T>>) {
|
||||
// Tests that the type argument in port gets
|
||||
// visited
|
||||
let p = Port::<T>();
|
||||
send(oc, Chan(p));
|
||||
send(oc, Chan(&p));
|
||||
|
||||
let x = recv(p);
|
||||
send(c, x);
|
||||
|
@ -10,7 +10,7 @@ fn a(c: Chan<int>) { send(c, 10); }
|
||||
|
||||
fn main() {
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
task::spawn(|| a(ch) );
|
||||
task::spawn(|| a(ch) );
|
||||
let mut n: int = 0;
|
||||
|
@ -10,7 +10,7 @@ fn a(c: Chan<int>) { debug!("task a0"); debug!("task a1"); send(c, 10); }
|
||||
|
||||
fn main() {
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
task::spawn(|| a(ch) );
|
||||
task::spawn(|| b(ch) );
|
||||
let mut n: int = 0;
|
||||
|
@ -29,7 +29,7 @@ fn main() {
|
||||
let mut n: int = 2 + 3 * 7;
|
||||
let s: ~str = ~"hello there";
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
task::spawn(|| a(ch) );
|
||||
task::spawn(|| b(ch) );
|
||||
let mut x: int = 10;
|
||||
|
@ -17,7 +17,7 @@ use comm::*;
|
||||
|
||||
fn foo(&&x: ()) -> Port<()> {
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
let c = Chan(&p);
|
||||
do task::spawn() |copy c, copy x| {
|
||||
c.send(x);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ type ctx = Chan<request>;
|
||||
|
||||
fn request_task(c: Chan<ctx>) {
|
||||
let p = Port();
|
||||
send(c, Chan(p));
|
||||
send(c, Chan(&p));
|
||||
let mut req: request;
|
||||
req = recv(p);
|
||||
// Need to drop req before receiving it again
|
||||
@ -21,7 +21,7 @@ fn request_task(c: Chan<ctx>) {
|
||||
|
||||
fn new_cx() -> ctx {
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
let t = task::spawn(|| request_task(ch) );
|
||||
let mut cx: ctx;
|
||||
cx = recv(p);
|
||||
@ -32,6 +32,6 @@ fn main() {
|
||||
let cx = new_cx();
|
||||
|
||||
let p = Port::<bool>();
|
||||
send(cx, close(Chan(p)));
|
||||
send(cx, close(Chan(&p)));
|
||||
send(cx, quit);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use comm::recv;
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
let t = task::spawn(|| child(ch) );
|
||||
let y = recv(p);
|
||||
error!("received");
|
||||
|
@ -8,7 +8,7 @@ use comm::recv;
|
||||
|
||||
fn main() {
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
let ch = Chan(&po);
|
||||
send(ch, 10);
|
||||
let i = recv(po);
|
||||
assert (i == 10);
|
||||
|
@ -47,7 +47,7 @@ mod map_reduce {
|
||||
None => {
|
||||
let p = Port();
|
||||
error!("sending find_reducer");
|
||||
send(ctrl, find_reducer(str::to_bytes(key), Chan(p)));
|
||||
send(ctrl, find_reducer(str::to_bytes(key), Chan(&p)));
|
||||
error!("receiving");
|
||||
c = recv(p);
|
||||
log(error, c);
|
||||
@ -70,7 +70,7 @@ mod map_reduce {
|
||||
|
||||
reducers = map::HashMap();
|
||||
|
||||
start_mappers(Chan(ctrl), inputs);
|
||||
start_mappers(Chan(&ctrl), inputs);
|
||||
|
||||
let mut num_mappers = vec::len(inputs) as int;
|
||||
|
||||
|
@ -20,7 +20,7 @@ fn child(c: Chan<int>) {
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
|
||||
task::spawn(|| child(ch) );
|
||||
|
||||
|
@ -14,7 +14,7 @@ fn producer(c: Chan<~[u8]>) {
|
||||
|
||||
fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
|
||||
let p: Port<~[u8]> = Port();
|
||||
send(cb, Chan(p));
|
||||
send(cb, Chan(&p));
|
||||
loop {
|
||||
debug!("waiting for bytes");
|
||||
let data = recv(p);
|
||||
@ -35,9 +35,9 @@ fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
|
||||
|
||||
fn main() {
|
||||
let p: Port<msg> = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
let recv_reader: Port<Chan<~[u8]>> = Port();
|
||||
let recv_reader_chan = Chan(recv_reader);
|
||||
let recv_reader_chan = Chan(&recv_reader);
|
||||
let pack = task::spawn(|| packager(recv_reader_chan, ch) );
|
||||
|
||||
let source_chan: Chan<~[u8]> = recv(recv_reader);
|
||||
|
@ -6,10 +6,10 @@ fn a() {
|
||||
fn doit() {
|
||||
fn b(c: Chan<Chan<int>>) {
|
||||
let p = Port();
|
||||
send(c, Chan(p));
|
||||
send(c, Chan(&p));
|
||||
}
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
spawn(|| b(ch) );
|
||||
recv(p);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ fn producer(c: Chan<~[u8]>) {
|
||||
|
||||
fn main() {
|
||||
let p: Port<~[u8]> = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
let prod = task::spawn(|| producer(ch) );
|
||||
|
||||
let data: ~[u8] = recv(p);
|
||||
|
@ -5,7 +5,7 @@ use comm::*;
|
||||
|
||||
fn main() {
|
||||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let ch = Chan(&p);
|
||||
let mut y: int;
|
||||
|
||||
task::spawn(|| child(ch) );
|
||||
|
@ -7,7 +7,7 @@ fn sub(parent: comm::Chan<int>, id: int) {
|
||||
comm::send(parent, 0);
|
||||
} else {
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
let child = task::spawn(|| sub(ch, id - 1) );
|
||||
let y = comm::recv(p);
|
||||
comm::send(parent, y + 1);
|
||||
@ -16,7 +16,7 @@ fn sub(parent: comm::Chan<int>, id: int) {
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
let child = task::spawn(|| sub(ch, 200) );
|
||||
let y = comm::recv(p);
|
||||
debug!("transmission complete");
|
||||
|
@ -18,7 +18,7 @@ type record = {val1: u32, val2: u32, val3: u32};
|
||||
// assertions.
|
||||
fn test_init() {
|
||||
let myport = Port();
|
||||
let mychan = Chan(myport);
|
||||
let mychan = Chan(&myport);
|
||||
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
|
||||
send(mychan, val);
|
||||
}
|
||||
@ -28,7 +28,7 @@ fn test_init() {
|
||||
// Don't trigger any assertions.
|
||||
fn test_grow() {
|
||||
let myport = Port();
|
||||
let mychan = Chan(myport);
|
||||
let mychan = Chan(&myport);
|
||||
for uint::range(0u, 100u) |i| {
|
||||
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
|
||||
comm::send(mychan, val);
|
||||
@ -39,14 +39,14 @@ fn test_grow() {
|
||||
// Don't allow the buffer to shrink below it's original size
|
||||
fn test_shrink1() {
|
||||
let myport = Port();
|
||||
let mychan = Chan(myport);
|
||||
let mychan = Chan(&myport);
|
||||
send(mychan, 0i8);
|
||||
let x = recv(myport);
|
||||
}
|
||||
|
||||
fn test_shrink2() {
|
||||
let myport = Port();
|
||||
let mychan = Chan(myport);
|
||||
let mychan = Chan(&myport);
|
||||
for uint::range(0u, 100u) |_i| {
|
||||
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
|
||||
send(mychan, val);
|
||||
@ -58,7 +58,7 @@ fn test_shrink2() {
|
||||
// Test rotating the buffer when the unit size is not a power of two
|
||||
fn test_rotate() {
|
||||
let myport = Port();
|
||||
let mychan = Chan(myport);
|
||||
let mychan = Chan(&myport);
|
||||
for uint::range(0u, 100u) |i| {
|
||||
let val = {val1: i as u32, val2: i as u32, val3: i as u32};
|
||||
send(mychan, val);
|
||||
@ -74,7 +74,7 @@ fn test_rotate() {
|
||||
// the unit size is not a power of two
|
||||
fn test_rotate_grow() {
|
||||
let myport = Port::<record>();
|
||||
let mychan = Chan(myport);
|
||||
let mychan = Chan(&myport);
|
||||
for uint::range(0u, 10u) |j| {
|
||||
for uint::range(0u, 10u) |i| {
|
||||
let val: record =
|
||||
|
@ -18,7 +18,7 @@ extern mod rustrt {
|
||||
|
||||
fn main() unsafe {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
let parent_sched_id = rustrt::rust_get_sched_id();
|
||||
error!("parent %?", parent_sched_id);
|
||||
let num_threads = 1u;
|
||||
|
@ -8,7 +8,7 @@ fn die() {
|
||||
fn iloop() {
|
||||
task::spawn(|| die() );
|
||||
let p = comm::Port::<()>();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
loop {
|
||||
// Sending and receiving here because these actions yield,
|
||||
// at which point our child can kill us
|
||||
|
@ -14,11 +14,11 @@ fn test(f: int) -> test {
|
||||
|
||||
fn main() {
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
let c = Chan(&p);
|
||||
|
||||
do spawn() {
|
||||
let p = Port();
|
||||
c.send(Chan(p));
|
||||
c.send(Chan(&p));
|
||||
|
||||
let _r = p.recv();
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ type command<K: Send, V: Send> = {key: K, val: V};
|
||||
|
||||
fn cache_server<K: Send, V: Send>(c: Chan<Chan<command<K, V>>>) {
|
||||
let ctrl = Port();
|
||||
send(c, Chan(ctrl));
|
||||
send(c, Chan(&ctrl));
|
||||
}
|
||||
fn main() { }
|
||||
|
@ -14,6 +14,6 @@ fn foo(i:int, j: char) -> foo {
|
||||
|
||||
fn main() {
|
||||
let po = comm::Port::<foo>();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
comm::send(ch, foo(42, 'c'));
|
||||
}
|
@ -15,6 +15,6 @@ fn iotask(cx: ctx, ip: ~str) {
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port::<int>();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
task::spawn(|| iotask(ch, ~"localhost") );
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ extern mod std;
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
comm::send(c, ~"coffee");
|
||||
}
|
@ -2,6 +2,6 @@ extern mod std;
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
comm::send(c, ~"coffee");
|
||||
}
|
@ -3,7 +3,7 @@ extern mod std;
|
||||
fn main() {
|
||||
let c = {
|
||||
let p = comm::Port();
|
||||
comm::Chan(p)
|
||||
comm::Chan(&p)
|
||||
};
|
||||
comm::send(c, ~"coffee");
|
||||
}
|
@ -12,7 +12,7 @@ fn starship(&&ch: comm::Chan<~str>) {
|
||||
fn starbase() {
|
||||
for int::range(0, 10) |_i| {
|
||||
let p = comm::Port();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
task::spawn(|| starship(c) );
|
||||
task::yield();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ extern mod std;
|
||||
// or not this is desirable I don't know, but here's a regression test.
|
||||
fn main() {
|
||||
let po = comm::Port();
|
||||
let ch = comm::Chan(po);
|
||||
let ch = comm::Chan(&po);
|
||||
comm::send(ch, ());
|
||||
let n: () = comm::recv(po);
|
||||
assert (n == ());
|
||||
|
@ -32,7 +32,7 @@ fn test00() {
|
||||
debug!("Creating tasks");
|
||||
|
||||
let po = Port();
|
||||
let ch = Chan(po);
|
||||
let ch = Chan(&po);
|
||||
|
||||
let mut i: int = 0;
|
||||
|
||||
@ -69,7 +69,7 @@ fn test01() {
|
||||
|
||||
fn test02() {
|
||||
let p = Port();
|
||||
let c = Chan(p);
|
||||
let c = Chan(&p);
|
||||
debug!("Writing to a local task channel.");
|
||||
send(c, 42);
|
||||
debug!("Reading from a local task port.");
|
||||
@ -101,7 +101,7 @@ fn test05_start(ch: Chan<int>) {
|
||||
|
||||
fn test05() {
|
||||
let po = comm::Port();
|
||||
let ch = Chan(po);
|
||||
let ch = Chan(&po);
|
||||
task::spawn(|| test05_start(ch) );
|
||||
let mut value: int;
|
||||
value = recv(po);
|
||||
|
@ -36,7 +36,7 @@ fn joinable(+f: fn~()) -> comm::Port<bool> {
|
||||
*b = true;
|
||||
}
|
||||
let p = comm::Port();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
do task::spawn_unlinked { wrapper(c, copy f) };
|
||||
p
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let p = comm::Port::<uint>();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
|
||||
let x = ~1;
|
||||
let x_in_parent = ptr::addr_of(&(*x)) as uint;
|
||||
|
@ -6,7 +6,7 @@ fn child(c: comm::Chan<~uint>, i: uint) {
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let ch = comm::Chan(p);
|
||||
let ch = comm::Chan(&p);
|
||||
let n = 100u;
|
||||
let mut expected = 0u;
|
||||
for uint::range(0u, n) |i| {
|
||||
|
@ -2,7 +2,7 @@ extern mod std;
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
comm::send(c, ~100);
|
||||
let v = comm::recv(p);
|
||||
assert v == ~100;
|
||||
|
@ -22,7 +22,7 @@ fn f(c: comm::Chan<bool>) {
|
||||
|
||||
fn main() {
|
||||
let p = comm::Port();
|
||||
let c = comm::Chan(p);
|
||||
let c = comm::Chan(&p);
|
||||
task::spawn_unlinked(|| f(c) );
|
||||
error!("hiiiiiiiii");
|
||||
assert comm::recv(p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user