Skip to content

Commit ed4fac0

Browse files
committed
Rename Send trait to Owned
1 parent a277081 commit ed4fac0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+290
-279
lines changed

src/libcore/comm.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use libc::size_t;
5757
* transmitted. If a port value is copied, both copies refer to the same
5858
* port. Ports may be associated with multiple `chan`s.
5959
*/
60-
pub enum Port<T: Send> {
60+
pub enum Port<T: Owned> {
6161
Port_(@PortPtr<T>)
6262
}
6363

@@ -73,16 +73,16 @@ pub enum Port<T: Send> {
7373
* data will be silently dropped. Channels may be duplicated and
7474
* themselves transmitted over other channels.
7575
*/
76-
pub enum Chan<T: Send> {
76+
pub enum Chan<T: Owned> {
7777
Chan_(port_id)
7878
}
7979

8080
/// Constructs a port
81-
pub fn Port<T: Send>() -> Port<T> {
81+
pub fn Port<T: Owned>() -> Port<T> {
8282
Port_(@PortPtr(rustrt::new_port(sys::size_of::<T>() as size_t)))
8383
}
8484

85-
impl<T: Send> Port<T> {
85+
impl<T: Owned> Port<T> {
8686

8787
fn chan() -> Chan<T> { Chan(&self) }
8888
fn send(v: T) { self.chan().send(move v) }
@@ -91,7 +91,7 @@ impl<T: Send> Port<T> {
9191

9292
}
9393

94-
impl<T: Send> Chan<T> {
94+
impl<T: Owned> Chan<T> {
9595

9696
fn chan() -> Chan<T> { self }
9797
fn send(v: T) { send(self, move v) }
@@ -101,12 +101,12 @@ impl<T: Send> Chan<T> {
101101
}
102102

103103
/// 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 {
105105
let po = Port();
106106
f(po.chan())
107107
}
108108

109-
struct PortPtr<T:Send> {
109+
struct PortPtr<T:Owned> {
110110
po: *rust_port,
111111
drop unsafe {
112112
do task::unkillable {
@@ -130,7 +130,7 @@ struct PortPtr<T:Send> {
130130
}
131131
}
132132

133-
fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
133+
fn PortPtr<T: Owned>(po: *rust_port) -> PortPtr<T> {
134134
PortPtr {
135135
po: po
136136
}
@@ -144,7 +144,7 @@ fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
144144
* Fails if the port is detached or dead. Fails if the port
145145
* is owned by a different task.
146146
*/
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 {
148148

149149
struct PortRef {
150150
p: *rust_port,
@@ -176,15 +176,15 @@ fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
176176
* Constructs a channel. The channel is bound to the port used to
177177
* construct it.
178178
*/
179-
pub fn Chan<T: Send>(p: &Port<T>) -> Chan<T> {
179+
pub fn Chan<T: Owned>(p: &Port<T>) -> Chan<T> {
180180
Chan_(rustrt::get_port_id((**p).po))
181181
}
182182

183183
/**
184184
* Sends data over a channel. The sent data is moved into the channel,
185185
* whereupon the caller loses access to it.
186186
*/
187-
pub fn send<T: Send>(ch: Chan<T>, data: T) {
187+
pub fn send<T: Owned>(ch: Chan<T>, data: T) {
188188
let Chan_(p) = ch;
189189
let data_ptr = ptr::addr_of(&data) as *();
190190
let res = rustrt::rust_port_id_send(p, data_ptr);
@@ -199,22 +199,22 @@ pub fn send<T: Send>(ch: Chan<T>, data: T) {
199199
* Receive from a port. If no data is available on the port then the
200200
* task will block until data becomes available.
201201
*/
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) }
203203

204204
/// 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) }
206206

207207
#[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 {
209209
as_raw_port(ch, |x|recv_(x))
210210
}
211211

212-
fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
212+
fn peek_chan<T: Owned>(ch: comm::Chan<T>) -> bool {
213213
as_raw_port(ch, |x|peek_(x))
214214
}
215215

216216
/// Receive on a raw port pointer
217-
fn recv_<T: Send>(p: *rust_port) -> T {
217+
fn recv_<T: Owned>(p: *rust_port) -> T {
218218
let yield = 0;
219219
let yieldp = ptr::addr_of(&yield);
220220
let mut res;
@@ -240,7 +240,7 @@ fn peek_(p: *rust_port) -> bool {
240240
}
241241

242242
/// 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>)
244244
-> Either<A, B> {
245245
let ports = ~[(**p_a).po, (**p_b).po];
246246
let yield = 0, yieldp = ptr::addr_of(&yield);

src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub mod util;
167167

168168
/* Reexported core operators */
169169

170-
pub use kinds::{Const, Copy, Send, Durable};
170+
pub use kinds::{Const, Copy, Owned, Durable};
171171
pub use ops::{Drop};
172172
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
173173
pub use ops::{BitAnd, BitOr, BitXor};

src/libcore/kinds.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The 4 kinds are
2424
scalar types and managed pointers, and exludes owned pointers. It
2525
also excludes types that implement `Drop`.
2626
27-
* Send - owned types and types containing owned types. These types
27+
* Owned - owned types and types containing owned types. These types
2828
may be transferred across task boundaries.
2929
3030
* Const - types that are deeply immutable. Const types are used for
@@ -44,8 +44,17 @@ pub trait Copy {
4444
// Empty.
4545
}
4646

47+
#[cfg(stage0)]
4748
#[lang="send"]
48-
pub trait Send {
49+
pub trait Owned {
50+
// Empty.
51+
}
52+
53+
#[cfg(stage1)]
54+
#[cfg(stage2)]
55+
#[cfg(stage3)]
56+
#[lang="owned"]
57+
pub trait Owned {
4958
// Empty.
5059
}
5160

0 commit comments

Comments
 (0)