diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index c3ed8c8c82c5..9f272b504088 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -30,15 +30,6 @@ use either::Either; use libc::size_t; -export Port; -export Chan; -export send; -export recv; -export peek; -export recv_chan; -export select2; -export methods; -export listen; /** @@ -48,7 +39,7 @@ export listen; * transmitted. If a port value is copied, both copies refer to the same * port. Ports may be associated with multiple `chan`s. */ -enum Port { +pub enum Port { Port_(@PortPtr) } @@ -64,12 +55,12 @@ enum Port { * data will be silently dropped. Channels may be duplicated and * themselves transmitted over other channels. */ -enum Chan { +pub enum Chan { Chan_(port_id) } /// Constructs a port -fn Port() -> Port { +pub fn Port() -> Port { Port_(@PortPtr(rustrt::new_port(sys::size_of::() as size_t))) } @@ -92,7 +83,7 @@ impl Chan { } /// Open a new receiving channel for the duration of a function -fn listen(f: fn(Chan) -> U) -> U { +pub fn listen(f: fn(Chan) -> U) -> U { let po = Port(); f(po.chan()) } @@ -167,7 +158,7 @@ fn as_raw_port(ch: comm::Chan, f: fn(*rust_port) -> U) -> U { * Constructs a channel. The channel is bound to the port used to * construct it. */ -fn Chan(p: Port) -> Chan { +pub fn Chan(p: Port) -> Chan { Chan_(rustrt::get_port_id((**p).po)) } @@ -175,7 +166,7 @@ fn Chan(p: Port) -> Chan { * Sends data over a channel. The sent data is moved into the channel, * whereupon the caller loses access to it. */ -fn send(ch: Chan, +data: T) { +pub fn send(ch: Chan, +data: T) { let Chan_(p) = ch; let data_ptr = ptr::addr_of(data) as *(); let res = rustrt::rust_port_id_send(p, data_ptr); @@ -190,13 +181,13 @@ fn send(ch: Chan, +data: T) { * Receive from a port. If no data is available on the port then the * task will block until data becomes available. */ -fn recv(p: Port) -> T { recv_((**p).po) } +pub fn recv(p: Port) -> T { recv_((**p).po) } /// Returns true if there are messages available -fn peek(p: Port) -> bool { peek_((**p).po) } +pub fn peek(p: Port) -> bool { peek_((**p).po) } #[doc(hidden)] -fn recv_chan(ch: comm::Chan) -> T { +pub fn recv_chan(ch: comm::Chan) -> T { as_raw_port(ch, |x|recv_(x)) } @@ -231,7 +222,7 @@ fn peek_(p: *rust_port) -> bool { } /// Receive on one of two ports -fn select2(p_a: Port, p_b: Port) +pub fn select2(p_a: Port, p_b: Port) -> Either { let ports = ~[(**p_a).po, (**p_b).po]; let yield = 0, yieldp = ptr::addr_of(yield);