Skip to content

Commit c096f7d

Browse files
committed
librustc: Change "Owned" to "Send" everywhere
1 parent c8bce58 commit c096f7d

Some content is hidden

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

54 files changed

+221
-221
lines changed

src/libextra/arc.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ impl<'self> Condvar<'self> {
112112
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
113113

114114
/// Create an atomically reference counted wrapper.
115-
pub fn ARC<T:Freeze + Owned>(data: T) -> ARC<T> {
115+
pub fn ARC<T:Freeze + Send>(data: T) -> ARC<T> {
116116
ARC { x: UnsafeAtomicRcBox::new(data) }
117117
}
118118

119119
/**
120120
* Access the underlying data in an atomically reference counted
121121
* wrapper.
122122
*/
123-
impl<T:Freeze+Owned> ARC<T> {
123+
impl<T:Freeze+Send> ARC<T> {
124124
pub fn get<'a>(&'a self) -> &'a T {
125125
unsafe { &*self.x.get_immut() }
126126
}
@@ -133,7 +133,7 @@ impl<T:Freeze+Owned> ARC<T> {
133133
* object. However, one of the `arc` objects can be sent to another task,
134134
* allowing them to share the underlying data.
135135
*/
136-
impl<T:Freeze + Owned> Clone for ARC<T> {
136+
impl<T:Freeze + Send> Clone for ARC<T> {
137137
fn clone(&self) -> ARC<T> {
138138
ARC { x: self.x.clone() }
139139
}
@@ -149,22 +149,22 @@ struct MutexARCInner<T> { lock: Mutex, failed: bool, data: T }
149149
struct MutexARC<T> { x: UnsafeAtomicRcBox<MutexARCInner<T>> }
150150

151151
/// Create a mutex-protected ARC with the supplied data.
152-
pub fn MutexARC<T:Owned>(user_data: T) -> MutexARC<T> {
152+
pub fn MutexARC<T:Send>(user_data: T) -> MutexARC<T> {
153153
mutex_arc_with_condvars(user_data, 1)
154154
}
155155
/**
156156
* Create a mutex-protected ARC with the supplied data and a specified number
157157
* of condvars (as sync::mutex_with_condvars).
158158
*/
159-
pub fn mutex_arc_with_condvars<T:Owned>(user_data: T,
159+
pub fn mutex_arc_with_condvars<T:Send>(user_data: T,
160160
num_condvars: uint) -> MutexARC<T> {
161161
let data =
162162
MutexARCInner { lock: mutex_with_condvars(num_condvars),
163163
failed: false, data: user_data };
164164
MutexARC { x: UnsafeAtomicRcBox::new(data) }
165165
}
166166

167-
impl<T:Owned> Clone for MutexARC<T> {
167+
impl<T:Send> Clone for MutexARC<T> {
168168
/// Duplicate a mutex-protected ARC, as arc::clone.
169169
fn clone(&self) -> MutexARC<T> {
170170
// NB: Cloning the underlying mutex is not necessary. Its reference
@@ -173,7 +173,7 @@ impl<T:Owned> Clone for MutexARC<T> {
173173
}
174174
}
175175

176-
impl<T:Owned> MutexARC<T> {
176+
impl<T:Send> MutexARC<T> {
177177

178178
/**
179179
* Access the underlying mutable data with mutual exclusion from other
@@ -285,14 +285,14 @@ struct RWARC<T> {
285285
}
286286

287287
/// Create a reader/writer ARC with the supplied data.
288-
pub fn RWARC<T:Freeze + Owned>(user_data: T) -> RWARC<T> {
288+
pub fn RWARC<T:Freeze + Send>(user_data: T) -> RWARC<T> {
289289
rw_arc_with_condvars(user_data, 1)
290290
}
291291
/**
292292
* Create a reader/writer ARC with the supplied data and a specified number
293293
* of condvars (as sync::rwlock_with_condvars).
294294
*/
295-
pub fn rw_arc_with_condvars<T:Freeze + Owned>(
295+
pub fn rw_arc_with_condvars<T:Freeze + Send>(
296296
user_data: T,
297297
num_condvars: uint) -> RWARC<T>
298298
{
@@ -302,7 +302,7 @@ pub fn rw_arc_with_condvars<T:Freeze + Owned>(
302302
RWARC { x: UnsafeAtomicRcBox::new(data), cant_nest: () }
303303
}
304304

305-
impl<T:Freeze + Owned> RWARC<T> {
305+
impl<T:Freeze + Send> RWARC<T> {
306306
/// Duplicate a rwlock-protected ARC, as arc::clone.
307307
pub fn clone(&self) -> RWARC<T> {
308308
RWARC {
@@ -313,7 +313,7 @@ impl<T:Freeze + Owned> RWARC<T> {
313313

314314
}
315315

316-
impl<T:Freeze + Owned> RWARC<T> {
316+
impl<T:Freeze + Send> RWARC<T> {
317317
/**
318318
* Access the underlying data mutably. Locks the rwlock in write mode;
319319
* other readers and writers will block.
@@ -439,7 +439,7 @@ impl<T:Freeze + Owned> RWARC<T> {
439439
// lock it. This wraps the unsafety, with the justification that the 'lock'
440440
// field is never overwritten; only 'failed' and 'data'.
441441
#[doc(hidden)]
442-
fn borrow_rwlock<T:Freeze + Owned>(state: *const RWARCInner<T>) -> *RWlock {
442+
fn borrow_rwlock<T:Freeze + Send>(state: *const RWARCInner<T>) -> *RWlock {
443443
unsafe { cast::transmute(&const (*state).lock) }
444444
}
445445

@@ -456,7 +456,7 @@ pub struct RWReadMode<'self, T> {
456456
token: sync::RWlockReadMode<'self>,
457457
}
458458

459-
impl<'self, T:Freeze + Owned> RWWriteMode<'self, T> {
459+
impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
460460
/// Access the pre-downgrade RWARC in write mode.
461461
pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
462462
match *self {
@@ -497,7 +497,7 @@ impl<'self, T:Freeze + Owned> RWWriteMode<'self, T> {
497497
}
498498
}
499499

500-
impl<'self, T:Freeze + Owned> RWReadMode<'self, T> {
500+
impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
501501
/// Access the post-downgrade rwlock in read mode.
502502
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
503503
match *self {

src/libextra/comm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct DuplexStream<T, U> {
3030
}
3131

3232
// Allow these methods to be used without import:
33-
impl<T:Owned,U:Owned> DuplexStream<T, U> {
33+
impl<T:Send,U:Send> DuplexStream<T, U> {
3434
pub fn send(&self, x: T) {
3535
self.chan.send(x)
3636
}
@@ -48,19 +48,19 @@ impl<T:Owned,U:Owned> DuplexStream<T, U> {
4848
}
4949
}
5050

51-
impl<T:Owned,U:Owned> GenericChan<T> for DuplexStream<T, U> {
51+
impl<T:Send,U:Send> GenericChan<T> for DuplexStream<T, U> {
5252
fn send(&self, x: T) {
5353
self.chan.send(x)
5454
}
5555
}
5656

57-
impl<T:Owned,U:Owned> GenericSmartChan<T> for DuplexStream<T, U> {
57+
impl<T:Send,U:Send> GenericSmartChan<T> for DuplexStream<T, U> {
5858
fn try_send(&self, x: T) -> bool {
5959
self.chan.try_send(x)
6060
}
6161
}
6262

63-
impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> {
63+
impl<T:Send,U:Send> GenericPort<U> for DuplexStream<T, U> {
6464
fn recv(&self) -> U {
6565
self.port.recv()
6666
}
@@ -70,20 +70,20 @@ impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> {
7070
}
7171
}
7272

73-
impl<T:Owned,U:Owned> Peekable<U> for DuplexStream<T, U> {
73+
impl<T:Send,U:Send> Peekable<U> for DuplexStream<T, U> {
7474
fn peek(&self) -> bool {
7575
self.port.peek()
7676
}
7777
}
7878

79-
impl<T:Owned,U:Owned> Selectable for DuplexStream<T, U> {
79+
impl<T:Send,U:Send> Selectable for DuplexStream<T, U> {
8080
fn header(&mut self) -> *mut pipes::PacketHeader {
8181
self.port.header()
8282
}
8383
}
8484

8585
/// Creates a bidirectional stream.
86-
pub fn DuplexStream<T:Owned,U:Owned>()
86+
pub fn DuplexStream<T:Send,U:Send>()
8787
-> (DuplexStream<T, U>, DuplexStream<U, T>)
8888
{
8989
let (p1, c2) = comm::stream();

src/libextra/flatpipes.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ Constructors for flat pipes that send POD types using memcpy.
166166
167167
# Safety Note
168168
169-
This module is currently unsafe because it uses `Copy Owned` as a type
170-
parameter bounds meaning POD (plain old data), but `Copy Owned` and
169+
This module is currently unsafe because it uses `Copy Send` as a type
170+
parameter bounds meaning POD (plain old data), but `Copy Send` and
171171
POD are not equivelant.
172172
173173
*/
@@ -191,7 +191,7 @@ pub mod pod {
191191
pub type PipeChan<T> = FlatChan<T, PodFlattener<T>, PipeByteChan>;
192192

193193
/// Create a `FlatPort` from a `Reader`
194-
pub fn reader_port<T:Copy + Owned,R:Reader>(
194+
pub fn reader_port<T:Copy + Send,R:Reader>(
195195
reader: R
196196
) -> ReaderPort<T, R> {
197197
let unflat: PodUnflattener<T> = PodUnflattener::new();
@@ -200,7 +200,7 @@ pub mod pod {
200200
}
201201

202202
/// Create a `FlatChan` from a `Writer`
203-
pub fn writer_chan<T:Copy + Owned,W:Writer>(
203+
pub fn writer_chan<T:Copy + Send,W:Writer>(
204204
writer: W
205205
) -> WriterChan<T, W> {
206206
let flat: PodFlattener<T> = PodFlattener::new();
@@ -209,21 +209,21 @@ pub mod pod {
209209
}
210210

211211
/// Create a `FlatPort` from a `Port<~[u8]>`
212-
pub fn pipe_port<T:Copy + Owned>(port: Port<~[u8]>) -> PipePort<T> {
212+
pub fn pipe_port<T:Copy + Send>(port: Port<~[u8]>) -> PipePort<T> {
213213
let unflat: PodUnflattener<T> = PodUnflattener::new();
214214
let byte_port = PipeBytePort::new(port);
215215
FlatPort::new(unflat, byte_port)
216216
}
217217

218218
/// Create a `FlatChan` from a `Chan<~[u8]>`
219-
pub fn pipe_chan<T:Copy + Owned>(chan: Chan<~[u8]>) -> PipeChan<T> {
219+
pub fn pipe_chan<T:Copy + Send>(chan: Chan<~[u8]>) -> PipeChan<T> {
220220
let flat: PodFlattener<T> = PodFlattener::new();
221221
let byte_chan = PipeByteChan::new(chan);
222222
FlatChan::new(flat, byte_chan)
223223
}
224224

225225
/// Create a pair of `FlatChan` and `FlatPort`, backed by pipes
226-
pub fn pipe_stream<T:Copy + Owned>() -> (PipePort<T>, PipeChan<T>) {
226+
pub fn pipe_stream<T:Copy + Send>() -> (PipePort<T>, PipeChan<T>) {
227227
let (port, chan) = comm::stream();
228228
return (pipe_port(port), pipe_chan(chan));
229229
}
@@ -352,7 +352,7 @@ pub mod flatteners {
352352
use core::sys::size_of;
353353
use core::vec;
354354

355-
// FIXME #4074: Copy + Owned != POD
355+
// FIXME #4074: Copy + Send != POD
356356
pub struct PodUnflattener<T> {
357357
bogus: ()
358358
}
@@ -361,7 +361,7 @@ pub mod flatteners {
361361
bogus: ()
362362
}
363363

364-
impl<T:Copy + Owned> Unflattener<T> for PodUnflattener<T> {
364+
impl<T:Copy + Send> Unflattener<T> for PodUnflattener<T> {
365365
fn unflatten(&self, buf: ~[u8]) -> T {
366366
assert!(size_of::<T>() != 0);
367367
assert_eq!(size_of::<T>(), buf.len());
@@ -371,7 +371,7 @@ pub mod flatteners {
371371
}
372372
}
373373

374-
impl<T:Copy + Owned> Flattener<T> for PodFlattener<T> {
374+
impl<T:Copy + Send> Flattener<T> for PodFlattener<T> {
375375
fn flatten(&self, val: T) -> ~[u8] {
376376
assert!(size_of::<T>() != 0);
377377
let val: *T = ptr::to_unsafe_ptr(&val);
@@ -380,15 +380,15 @@ pub mod flatteners {
380380
}
381381
}
382382

383-
impl<T:Copy + Owned> PodUnflattener<T> {
383+
impl<T:Copy + Send> PodUnflattener<T> {
384384
pub fn new() -> PodUnflattener<T> {
385385
PodUnflattener {
386386
bogus: ()
387387
}
388388
}
389389
}
390390

391-
impl<T:Copy + Owned> PodFlattener<T> {
391+
impl<T:Copy + Send> PodFlattener<T> {
392392
pub fn new() -> PodFlattener<T> {
393393
PodFlattener {
394394
bogus: ()

src/libextra/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn from_value<A>(val: A) -> Future<A> {
101101
Future {state: Forced(val)}
102102
}
103103

104-
pub fn from_port<A:Owned>(port: PortOne<A>) -> Future<A> {
104+
pub fn from_port<A:Send>(port: PortOne<A>) -> Future<A> {
105105
/*!
106106
* Create a future from a port
107107
*
@@ -127,7 +127,7 @@ pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> {
127127
Future {state: Pending(f)}
128128
}
129129

130-
pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> {
130+
pub fn spawn<A:Send>(blk: ~fn() -> A) -> Future<A> {
131131
/*!
132132
* Create a future from a unique closure.
133133
*

src/libextra/par.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static min_granularity : uint = 1024u;
3434
* This is used to build most of the other parallel vector functions,
3535
* like map or alli.
3636
*/
37-
fn map_slices<A:Copy + Owned,B:Copy + Owned>(
37+
fn map_slices<A:Copy + Send,B:Copy + Send>(
3838
xs: &[A],
3939
f: &fn() -> ~fn(uint, v: &[A]) -> B)
4040
-> ~[B] {
@@ -89,7 +89,7 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
8989
}
9090

9191
/// A parallel version of map.
92-
pub fn map<A:Copy + Owned,B:Copy + Owned>(
92+
pub fn map<A:Copy + Send,B:Copy + Send>(
9393
xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] {
9494
vec::concat(map_slices(xs, || {
9595
let f = fn_factory();
@@ -100,7 +100,7 @@ pub fn map<A:Copy + Owned,B:Copy + Owned>(
100100
}
101101

102102
/// A parallel version of mapi.
103-
pub fn mapi<A:Copy + Owned,B:Copy + Owned>(
103+
pub fn mapi<A:Copy + Send,B:Copy + Send>(
104104
xs: &[A],
105105
fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] {
106106
let slices = map_slices(xs, || {
@@ -119,7 +119,7 @@ pub fn mapi<A:Copy + Owned,B:Copy + Owned>(
119119
}
120120

121121
/// Returns true if the function holds for all elements in the vector.
122-
pub fn alli<A:Copy + Owned>(
122+
pub fn alli<A:Copy + Send>(
123123
xs: &[A],
124124
fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool
125125
{
@@ -134,7 +134,7 @@ pub fn alli<A:Copy + Owned>(
134134
}
135135

136136
/// Returns true if the function holds for any elements in the vector.
137-
pub fn any<A:Copy + Owned>(
137+
pub fn any<A:Copy + Send>(
138138
xs: &[A],
139139
fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
140140
let mapped = map_slices(xs, || {

src/libextra/rc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
/** Task-local reference counted smart pointers
1414
1515
Task-local reference counted smart pointers are an alternative to managed boxes with deterministic
16-
destruction. They are restricted to containing types that are either `Owned` or `Freeze` (or both) to
16+
destruction. They are restricted to containing types that are either `Send` or `Freeze` (or both) to
1717
prevent cycles.
1818
19-
Neither `Rc<T>` or `RcMut<T>` is ever `Owned` and `RcMut<T>` is never `Freeze`. If `T` is `Freeze`, a
19+
Neither `Rc<T>` or `RcMut<T>` is ever `Send` and `RcMut<T>` is never `Freeze`. If `T` is `Freeze`, a
2020
cycle cannot be created with `Rc<T>` because there is no way to modify it after creation.
2121
2222
*/
@@ -51,7 +51,7 @@ impl<T> Rc<T> {
5151
}
5252

5353
// FIXME: #6516: should be a static method
54-
pub fn rc_from_owned<T: Owned>(value: T) -> Rc<T> {
54+
pub fn rc_from_owned<T: Send>(value: T) -> Rc<T> {
5555
unsafe { Rc::new(value) }
5656
}
5757

@@ -182,7 +182,7 @@ impl<T> RcMut<T> {
182182
}
183183

184184
// FIXME: #6516: should be a static method
185-
pub fn rc_mut_from_owned<T: Owned>(value: T) -> RcMut<T> {
185+
pub fn rc_mut_from_owned<T: Send>(value: T) -> RcMut<T> {
186186
unsafe { RcMut::new(value) }
187187
}
188188

src/libextra/sync.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct SemInner<Q> {
8484
struct Sem<Q>(Exclusive<SemInner<Q>>);
8585

8686
#[doc(hidden)]
87-
fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> {
87+
fn new_sem<Q:Send>(count: int, q: Q) -> Sem<Q> {
8888
Sem(exclusive(SemInner {
8989
count: count, waiters: new_waitqueue(), blocked: q }))
9090
}
@@ -99,7 +99,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
9999
}
100100

101101
#[doc(hidden)]
102-
impl<Q:Owned> Sem<Q> {
102+
impl<Q:Send> Sem<Q> {
103103
pub fn acquire(&self) {
104104
unsafe {
105105
let mut waiter_nobe = None;
@@ -170,7 +170,7 @@ type SemAndSignalRelease<'self> = SemReleaseGeneric<'self, ~[Waitqueue]>;
170170
struct SemReleaseGeneric<'self, Q> { sem: &'self Sem<Q> }
171171

172172
#[unsafe_destructor]
173-
impl<'self, Q:Owned> Drop for SemReleaseGeneric<'self, Q> {
173+
impl<'self, Q:Send> Drop for SemReleaseGeneric<'self, Q> {
174174
fn finalize(&self) {
175175
self.sem.release();
176176
}

0 commit comments

Comments
 (0)