Skip to content

Commit 9193891

Browse files
committed
librustc: Change "Owned" to "Send" everywhere
1 parent 228e0a8 commit 9193891

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
@@ -113,15 +113,15 @@ impl<'self> Condvar<'self> {
113113
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
114114

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

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

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

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

177-
impl<T:Owned> MutexARC<T> {
177+
impl<T:Send> MutexARC<T> {
178178

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

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

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

315315
}
316316

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

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

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

501-
impl<'self, T:Freeze + Owned> RWReadMode<'self, T> {
501+
impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
502502
/// Access the post-downgrade rwlock in read mode.
503503
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
504504
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
@@ -33,7 +33,7 @@ static min_granularity : uint = 1024u;
3333
* This is used to build most of the other parallel vector functions,
3434
* like map or alli.
3535
*/
36-
fn map_slices<A:Copy + Owned,B:Copy + Owned>(
36+
fn map_slices<A:Copy + Send,B:Copy + Send>(
3737
xs: &[A],
3838
f: &fn() -> ~fn(uint, v: &[A]) -> B)
3939
-> ~[B] {
@@ -88,7 +88,7 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
8888
}
8989

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

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

120120
/// Returns true if the function holds for all elements in the vector.
121-
pub fn alli<A:Copy + Owned>(
121+
pub fn alli<A:Copy + Send>(
122122
xs: &[A],
123123
fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool
124124
{
@@ -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
do vec::any(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
@@ -85,7 +85,7 @@ struct SemInner<Q> {
8585
struct Sem<Q>(Exclusive<SemInner<Q>>);
8686

8787
#[doc(hidden)]
88-
fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> {
88+
fn new_sem<Q:Send>(count: int, q: Q) -> Sem<Q> {
8989
Sem(exclusive(SemInner {
9090
count: count, waiters: new_waitqueue(), blocked: q }))
9191
}
@@ -100,7 +100,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
100100
}
101101

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

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

0 commit comments

Comments
 (0)