@@ -57,7 +57,7 @@ use libc::size_t;
57
57
* transmitted. If a port value is copied, both copies refer to the same
58
58
* port. Ports may be associated with multiple `chan`s.
59
59
*/
60
- pub enum Port < T : Send > {
60
+ pub enum Port < T : Owned > {
61
61
Port_ ( @PortPtr < T > )
62
62
}
63
63
@@ -73,16 +73,16 @@ pub enum Port<T: Send> {
73
73
* data will be silently dropped. Channels may be duplicated and
74
74
* themselves transmitted over other channels.
75
75
*/
76
- pub enum Chan < T : Send > {
76
+ pub enum Chan < T : Owned > {
77
77
Chan_ ( port_id )
78
78
}
79
79
80
80
/// Constructs a port
81
- pub fn Port < T : Send > ( ) -> Port < T > {
81
+ pub fn Port < T : Owned > ( ) -> Port < T > {
82
82
Port_ ( @PortPtr ( rustrt:: new_port ( sys:: size_of :: < T > ( ) as size_t ) ) )
83
83
}
84
84
85
- impl < T : Send > Port < T > {
85
+ impl < T : Owned > Port < T > {
86
86
87
87
fn chan ( ) -> Chan < T > { Chan ( & self ) }
88
88
fn send ( v : T ) { self . chan ( ) . send ( move v) }
@@ -91,7 +91,7 @@ impl<T: Send> Port<T> {
91
91
92
92
}
93
93
94
- impl < T : Send > Chan < T > {
94
+ impl < T : Owned > Chan < T > {
95
95
96
96
fn chan ( ) -> Chan < T > { self }
97
97
fn send ( v : T ) { send ( self , move v) }
@@ -101,12 +101,12 @@ impl<T: Send> Chan<T> {
101
101
}
102
102
103
103
/// Open a new receiving channel for the duration of a function
104
- pub fn listen < T : Send , U > ( f : fn ( Chan < T > ) -> U ) -> U {
104
+ pub fn listen < T : Owned , U > ( f : fn ( Chan < T > ) -> U ) -> U {
105
105
let po = Port ( ) ;
106
106
f ( po. chan ( ) )
107
107
}
108
108
109
- struct PortPtr < T : Send > {
109
+ struct PortPtr < T : Owned > {
110
110
po : * rust_port ,
111
111
drop unsafe {
112
112
do task:: unkillable {
@@ -130,7 +130,7 @@ struct PortPtr<T:Send> {
130
130
}
131
131
}
132
132
133
- fn PortPtr < T : Send > ( po : * rust_port ) -> PortPtr < T > {
133
+ fn PortPtr < T : Owned > ( po : * rust_port ) -> PortPtr < T > {
134
134
PortPtr {
135
135
po : po
136
136
}
@@ -144,7 +144,7 @@ fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
144
144
* Fails if the port is detached or dead. Fails if the port
145
145
* is owned by a different task.
146
146
*/
147
- fn as_raw_port < T : Send , U > ( ch : comm:: Chan < T > , f : fn ( * rust_port ) -> U ) -> U {
147
+ fn as_raw_port < T : Owned , U > ( ch : comm:: Chan < T > , f : fn ( * rust_port ) -> U ) -> U {
148
148
149
149
struct PortRef {
150
150
p : * rust_port ,
@@ -176,15 +176,15 @@ fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
176
176
* Constructs a channel. The channel is bound to the port used to
177
177
* construct it.
178
178
*/
179
- pub fn Chan < T : Send > ( p : & Port < T > ) -> Chan < T > {
179
+ pub fn Chan < T : Owned > ( p : & Port < T > ) -> Chan < T > {
180
180
Chan_ ( rustrt:: get_port_id ( ( * * p) . po ) )
181
181
}
182
182
183
183
/**
184
184
* Sends data over a channel. The sent data is moved into the channel,
185
185
* whereupon the caller loses access to it.
186
186
*/
187
- pub fn send< T : Send > ( ch : Chan < T > , data : T ) {
187
+ pub fn send< T : Owned > ( ch : Chan < T > , data : T ) {
188
188
let Chan_ ( p) = ch;
189
189
let data_ptr = ptr:: addr_of ( & data) as * ( ) ;
190
190
let res = rustrt:: rust_port_id_send ( p, data_ptr) ;
@@ -199,22 +199,22 @@ pub fn send<T: Send>(ch: Chan<T>, data: T) {
199
199
* Receive from a port. If no data is available on the port then the
200
200
* task will block until data becomes available.
201
201
*/
202
- pub fn recv < T : Send > ( p : Port < T > ) -> T { recv_ ( ( * * p) . po ) }
202
+ pub fn recv < T : Owned > ( p : Port < T > ) -> T { recv_ ( ( * * p) . po ) }
203
203
204
204
/// Returns true if there are messages available
205
- pub fn peek < T : Send > ( p : Port < T > ) -> bool { peek_ ( ( * * p) . po ) }
205
+ pub fn peek < T : Owned > ( p : Port < T > ) -> bool { peek_ ( ( * * p) . po ) }
206
206
207
207
#[ doc( hidden) ]
208
- pub fn recv_chan < T : Send > ( ch : comm:: Chan < T > ) -> T {
208
+ pub fn recv_chan < T : Owned > ( ch : comm:: Chan < T > ) -> T {
209
209
as_raw_port ( ch, |x|recv_ ( x) )
210
210
}
211
211
212
- fn peek_chan < T : Send > ( ch : comm:: Chan < T > ) -> bool {
212
+ fn peek_chan < T : Owned > ( ch : comm:: Chan < T > ) -> bool {
213
213
as_raw_port ( ch, |x|peek_ ( x) )
214
214
}
215
215
216
216
/// Receive on a raw port pointer
217
- fn recv_ < T : Send > ( p : * rust_port ) -> T {
217
+ fn recv_ < T : Owned > ( p : * rust_port ) -> T {
218
218
let yield = 0 ;
219
219
let yieldp = ptr:: addr_of ( & yield ) ;
220
220
let mut res;
@@ -240,7 +240,7 @@ fn peek_(p: *rust_port) -> bool {
240
240
}
241
241
242
242
/// Receive on one of two ports
243
- pub fn select2 < A : Send , B : Send > ( p_a : Port < A > , p_b : Port < B > )
243
+ pub fn select2 < A : Owned , B : Owned > ( p_a : Port < A > , p_b : Port < B > )
244
244
-> Either < A , B > {
245
245
let ports = ~[ ( * * p_a) . po , ( * * p_b) . po ] ;
246
246
let yield = 0 , yieldp = ptr:: addr_of ( & yield ) ;
0 commit comments