diff options
Diffstat (limited to 'src/libcore/comm.rs')
| -rw-r--r-- | src/libcore/comm.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index f9d68975944..177ecdca9a2 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -48,7 +48,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<T: send> { +enum Port<T: Send> { Port_(@PortPtr<T>) } @@ -64,16 +64,16 @@ enum Port<T: send> { * data will be silently dropped. Channels may be duplicated and * themselves transmitted over other channels. */ -enum Chan<T: send> { +enum Chan<T: Send> { Chan_(port_id) } /// 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> { +impl<T: Send> Port<T> { fn chan() -> Chan<T> { Chan(self) } fn send(+v: T) { self.chan().send(v) } @@ -82,7 +82,7 @@ impl<T: send> Port<T> { } -impl<T: send> Chan<T> { +impl<T: Send> Chan<T> { fn chan() -> Chan<T> { self } fn send(+v: T) { send(self, v) } @@ -92,12 +92,12 @@ 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 { +fn listen<T: Send, U>(f: fn(Chan<T>) -> U) -> U { let po = Port(); f(po.chan()) } -struct PortPtr<T:send> { +struct PortPtr<T:Send> { po: *rust_port, drop unsafe { do task::unkillable { @@ -121,7 +121,7 @@ struct PortPtr<T:send> { } } -fn PortPtr<T: send>(po: *rust_port) -> PortPtr<T> { +fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> { PortPtr { po: po } @@ -135,7 +135,7 @@ fn PortPtr<T: send>(po: *rust_port) -> PortPtr<T> { * Fails if the port is detached or dead. Fails if the port * is owned by a different task. */ -fn as_raw_port<T: send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U { +fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U { struct PortRef { p: *rust_port, @@ -167,7 +167,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)) } @@ -175,7 +175,7 @@ fn Chan<T: send>(p: Port<T>) -> Chan<T> { * Sends data over a channel. The sent data is moved into the channel, * whereupon the caller loses access to it. */ -fn send<T: send>(ch: Chan<T>, +data: T) { +fn send<T: Send>(ch: Chan<T>, +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,22 +190,22 @@ fn send<T: send>(ch: Chan<T>, +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<T: send>(p: Port<T>) -> T { recv_((**p).po) } +fn recv<T: Send>(p: Port<T>) -> T { recv_((**p).po) } /// Returns true if there are messages available -fn peek<T: send>(p: Port<T>) -> bool { peek_((**p).po) } +fn peek<T: Send>(p: Port<T>) -> bool { peek_((**p).po) } #[doc(hidden)] -fn recv_chan<T: send>(ch: comm::Chan<T>) -> T { +fn recv_chan<T: Send>(ch: comm::Chan<T>) -> T { as_raw_port(ch, |x|recv_(x)) } -fn peek_chan<T: send>(ch: comm::Chan<T>) -> bool { +fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool { as_raw_port(ch, |x|peek_(x)) } /// Receive on a raw port pointer -fn recv_<T: send>(p: *rust_port) -> T { +fn recv_<T: Send>(p: *rust_port) -> T { let yield = 0u; let yieldp = ptr::addr_of(yield); let mut res; @@ -231,7 +231,7 @@ fn peek_(p: *rust_port) -> bool { } /// Receive on one of two ports -fn select2<A: send, B: send>(p_a: Port<A>, p_b: Port<B>) +fn select2<A: Send, B: Send>(p_a: Port<A>, p_b: Port<B>) -> Either<A, B> { let ports = ~[(**p_a).po, (**p_b).po]; let yield = 0u, yieldp = ptr::addr_of(yield); |
