librustc: Change "Owned" to "Send" everywhere

This commit is contained in:
Patrick Walton 2013-06-05 17:56:24 -07:00 committed by Corey Richardson
parent 1eec3bba13
commit 1c0aa78481
54 changed files with 222 additions and 222 deletions

View file

@ -112,7 +112,7 @@ impl<'self> Condvar<'self> {
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
/// Create an atomically reference counted wrapper.
pub fn ARC<T:Freeze + Owned>(data: T) -> ARC<T> {
pub fn ARC<T:Freeze + Send>(data: T) -> ARC<T> {
ARC { x: UnsafeAtomicRcBox::new(data) }
}
@ -120,7 +120,7 @@ pub fn ARC<T:Freeze + Owned>(data: T) -> ARC<T> {
* Access the underlying data in an atomically reference counted
* wrapper.
*/
impl<T:Freeze+Owned> ARC<T> {
impl<T:Freeze+Send> ARC<T> {
pub fn get<'a>(&'a self) -> &'a T {
unsafe { &*self.x.get_immut() }
}
@ -133,7 +133,7 @@ impl<T:Freeze+Owned> ARC<T> {
* object. However, one of the `arc` objects can be sent to another task,
* allowing them to share the underlying data.
*/
impl<T:Freeze + Owned> Clone for ARC<T> {
impl<T:Freeze + Send> Clone for ARC<T> {
fn clone(&self) -> ARC<T> {
ARC { x: self.x.clone() }
}
@ -149,14 +149,14 @@ struct MutexARCInner<T> { lock: Mutex, failed: bool, data: T }
struct MutexARC<T> { x: UnsafeAtomicRcBox<MutexARCInner<T>> }
/// Create a mutex-protected ARC with the supplied data.
pub fn MutexARC<T:Owned>(user_data: T) -> MutexARC<T> {
pub fn MutexARC<T:Send>(user_data: T) -> MutexARC<T> {
mutex_arc_with_condvars(user_data, 1)
}
/**
* Create a mutex-protected ARC with the supplied data and a specified number
* of condvars (as sync::mutex_with_condvars).
*/
pub fn mutex_arc_with_condvars<T:Owned>(user_data: T,
pub fn mutex_arc_with_condvars<T:Send>(user_data: T,
num_condvars: uint) -> MutexARC<T> {
let data =
MutexARCInner { lock: mutex_with_condvars(num_condvars),
@ -164,7 +164,7 @@ pub fn mutex_arc_with_condvars<T:Owned>(user_data: T,
MutexARC { x: UnsafeAtomicRcBox::new(data) }
}
impl<T:Owned> Clone for MutexARC<T> {
impl<T:Send> Clone for MutexARC<T> {
/// Duplicate a mutex-protected ARC, as arc::clone.
fn clone(&self) -> MutexARC<T> {
// NB: Cloning the underlying mutex is not necessary. Its reference
@ -173,7 +173,7 @@ impl<T:Owned> Clone for MutexARC<T> {
}
}
impl<T:Owned> MutexARC<T> {
impl<T:Send> MutexARC<T> {
/**
* Access the underlying mutable data with mutual exclusion from other
@ -282,14 +282,14 @@ struct RWARC<T> {
}
/// Create a reader/writer ARC with the supplied data.
pub fn RWARC<T:Freeze + Owned>(user_data: T) -> RWARC<T> {
pub fn RWARC<T:Freeze + Send>(user_data: T) -> RWARC<T> {
rw_arc_with_condvars(user_data, 1)
}
/**
* Create a reader/writer ARC with the supplied data and a specified number
* of condvars (as sync::rwlock_with_condvars).
*/
pub fn rw_arc_with_condvars<T:Freeze + Owned>(
pub fn rw_arc_with_condvars<T:Freeze + Send>(
user_data: T,
num_condvars: uint) -> RWARC<T>
{
@ -299,7 +299,7 @@ pub fn rw_arc_with_condvars<T:Freeze + Owned>(
RWARC { x: UnsafeAtomicRcBox::new(data), }
}
impl<T:Freeze + Owned> RWARC<T> {
impl<T:Freeze + Send> RWARC<T> {
/// Duplicate a rwlock-protected ARC, as arc::clone.
pub fn clone(&self) -> RWARC<T> {
RWARC {
@ -309,7 +309,7 @@ impl<T:Freeze + Owned> RWARC<T> {
}
impl<T:Freeze + Owned> RWARC<T> {
impl<T:Freeze + Send> RWARC<T> {
/**
* Access the underlying data mutably. Locks the rwlock in write mode;
* other readers and writers will block.
@ -435,7 +435,7 @@ impl<T:Freeze + Owned> RWARC<T> {
// lock it. This wraps the unsafety, with the justification that the 'lock'
// field is never overwritten; only 'failed' and 'data'.
#[doc(hidden)]
fn borrow_rwlock<T:Freeze + Owned>(state: *const RWARCInner<T>) -> *RWlock {
fn borrow_rwlock<T:Freeze + Send>(state: *const RWARCInner<T>) -> *RWlock {
unsafe { cast::transmute(&const (*state).lock) }
}
@ -452,7 +452,7 @@ pub struct RWReadMode<'self, T> {
token: sync::RWlockReadMode<'self>,
}
impl<'self, T:Freeze + Owned> RWWriteMode<'self, T> {
impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
/// Access the pre-downgrade RWARC in write mode.
pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
match *self {
@ -493,7 +493,7 @@ impl<'self, T:Freeze + Owned> RWWriteMode<'self, T> {
}
}
impl<'self, T:Freeze + Owned> RWReadMode<'self, T> {
impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
/// Access the post-downgrade rwlock in read mode.
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
match *self {

View file

@ -30,7 +30,7 @@ pub struct DuplexStream<T, U> {
}
// Allow these methods to be used without import:
impl<T:Owned,U:Owned> DuplexStream<T, U> {
impl<T:Send,U:Send> DuplexStream<T, U> {
pub fn send(&self, x: T) {
self.chan.send(x)
}
@ -48,19 +48,19 @@ impl<T:Owned,U:Owned> DuplexStream<T, U> {
}
}
impl<T:Owned,U:Owned> GenericChan<T> for DuplexStream<T, U> {
impl<T:Send,U:Send> GenericChan<T> for DuplexStream<T, U> {
fn send(&self, x: T) {
self.chan.send(x)
}
}
impl<T:Owned,U:Owned> GenericSmartChan<T> for DuplexStream<T, U> {
impl<T:Send,U:Send> GenericSmartChan<T> for DuplexStream<T, U> {
fn try_send(&self, x: T) -> bool {
self.chan.try_send(x)
}
}
impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> {
impl<T:Send,U:Send> GenericPort<U> for DuplexStream<T, U> {
fn recv(&self) -> U {
self.port.recv()
}
@ -70,20 +70,20 @@ impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> {
}
}
impl<T:Owned,U:Owned> Peekable<U> for DuplexStream<T, U> {
impl<T:Send,U:Send> Peekable<U> for DuplexStream<T, U> {
fn peek(&self) -> bool {
self.port.peek()
}
}
impl<T:Owned,U:Owned> Selectable for DuplexStream<T, U> {
impl<T:Send,U:Send> Selectable for DuplexStream<T, U> {
fn header(&mut self) -> *mut pipes::PacketHeader {
self.port.header()
}
}
/// Creates a bidirectional stream.
pub fn DuplexStream<T:Owned,U:Owned>()
pub fn DuplexStream<T:Send,U:Send>()
-> (DuplexStream<T, U>, DuplexStream<U, T>)
{
let (p1, c2) = comm::stream();

View file

@ -166,8 +166,8 @@ Constructors for flat pipes that send POD types using memcpy.
# Safety Note
This module is currently unsafe because it uses `Copy Owned` as a type
parameter bounds meaning POD (plain old data), but `Copy Owned` and
This module is currently unsafe because it uses `Copy Send` as a type
parameter bounds meaning POD (plain old data), but `Copy Send` and
POD are not equivelant.
*/
@ -191,7 +191,7 @@ pub mod pod {
pub type PipeChan<T> = FlatChan<T, PodFlattener<T>, PipeByteChan>;
/// Create a `FlatPort` from a `Reader`
pub fn reader_port<T:Copy + Owned,R:Reader>(
pub fn reader_port<T:Copy + Send,R:Reader>(
reader: R
) -> ReaderPort<T, R> {
let unflat: PodUnflattener<T> = PodUnflattener::new();
@ -200,7 +200,7 @@ pub mod pod {
}
/// Create a `FlatChan` from a `Writer`
pub fn writer_chan<T:Copy + Owned,W:Writer>(
pub fn writer_chan<T:Copy + Send,W:Writer>(
writer: W
) -> WriterChan<T, W> {
let flat: PodFlattener<T> = PodFlattener::new();
@ -209,21 +209,21 @@ pub mod pod {
}
/// Create a `FlatPort` from a `Port<~[u8]>`
pub fn pipe_port<T:Copy + Owned>(port: Port<~[u8]>) -> PipePort<T> {
pub fn pipe_port<T:Copy + Send>(port: Port<~[u8]>) -> PipePort<T> {
let unflat: PodUnflattener<T> = PodUnflattener::new();
let byte_port = PipeBytePort::new(port);
FlatPort::new(unflat, byte_port)
}
/// Create a `FlatChan` from a `Chan<~[u8]>`
pub fn pipe_chan<T:Copy + Owned>(chan: Chan<~[u8]>) -> PipeChan<T> {
pub fn pipe_chan<T:Copy + Send>(chan: Chan<~[u8]>) -> PipeChan<T> {
let flat: PodFlattener<T> = PodFlattener::new();
let byte_chan = PipeByteChan::new(chan);
FlatChan::new(flat, byte_chan)
}
/// Create a pair of `FlatChan` and `FlatPort`, backed by pipes
pub fn pipe_stream<T:Copy + Owned>() -> (PipePort<T>, PipeChan<T>) {
pub fn pipe_stream<T:Copy + Send>() -> (PipePort<T>, PipeChan<T>) {
let (port, chan) = comm::stream();
return (pipe_port(port), pipe_chan(chan));
}
@ -352,7 +352,7 @@ pub mod flatteners {
use core::sys::size_of;
use core::vec;
// FIXME #4074: Copy + Owned != POD
// FIXME #4074: Copy + Send != POD
pub struct PodUnflattener<T> {
bogus: ()
}
@ -361,7 +361,7 @@ pub mod flatteners {
bogus: ()
}
impl<T:Copy + Owned> Unflattener<T> for PodUnflattener<T> {
impl<T:Copy + Send> Unflattener<T> for PodUnflattener<T> {
fn unflatten(&self, buf: ~[u8]) -> T {
assert!(size_of::<T>() != 0);
assert_eq!(size_of::<T>(), buf.len());
@ -371,7 +371,7 @@ pub mod flatteners {
}
}
impl<T:Copy + Owned> Flattener<T> for PodFlattener<T> {
impl<T:Copy + Send> Flattener<T> for PodFlattener<T> {
fn flatten(&self, val: T) -> ~[u8] {
assert!(size_of::<T>() != 0);
let val: *T = ptr::to_unsafe_ptr(&val);
@ -380,7 +380,7 @@ pub mod flatteners {
}
}
impl<T:Copy + Owned> PodUnflattener<T> {
impl<T:Copy + Send> PodUnflattener<T> {
pub fn new() -> PodUnflattener<T> {
PodUnflattener {
bogus: ()
@ -388,7 +388,7 @@ pub mod flatteners {
}
}
impl<T:Copy + Owned> PodFlattener<T> {
impl<T:Copy + Send> PodFlattener<T> {
pub fn new() -> PodFlattener<T> {
PodFlattener {
bogus: ()

View file

@ -101,7 +101,7 @@ pub fn from_value<A>(val: A) -> Future<A> {
Future {state: Forced(val)}
}
pub fn from_port<A:Owned>(port: PortOne<A>) -> Future<A> {
pub fn from_port<A:Send>(port: PortOne<A>) -> Future<A> {
/*!
* Create a future from a port
*
@ -127,7 +127,7 @@ pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> {
Future {state: Pending(f)}
}
pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> {
pub fn spawn<A:Send>(blk: ~fn() -> A) -> Future<A> {
/*!
* Create a future from a unique closure.
*

View file

@ -33,7 +33,7 @@ static min_granularity : uint = 1024u;
* This is used to build most of the other parallel vector functions,
* like map or alli.
*/
fn map_slices<A:Copy + Owned,B:Copy + Owned>(
fn map_slices<A:Copy + Send,B:Copy + Send>(
xs: &[A],
f: &fn() -> ~fn(uint, v: &[A]) -> B)
-> ~[B] {
@ -88,7 +88,7 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
}
/// A parallel version of map.
pub fn map<A:Copy + Owned,B:Copy + Owned>(
pub fn map<A:Copy + Send,B:Copy + Send>(
xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] {
vec::concat(map_slices(xs, || {
let f = fn_factory();
@ -99,7 +99,7 @@ pub fn map<A:Copy + Owned,B:Copy + Owned>(
}
/// A parallel version of mapi.
pub fn mapi<A:Copy + Owned,B:Copy + Owned>(
pub fn mapi<A:Copy + Send,B:Copy + Send>(
xs: &[A],
fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] {
let slices = map_slices(xs, || {
@ -118,7 +118,7 @@ pub fn mapi<A:Copy + Owned,B:Copy + Owned>(
}
/// Returns true if the function holds for all elements in the vector.
pub fn alli<A:Copy + Owned>(
pub fn alli<A:Copy + Send>(
xs: &[A],
fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool
{
@ -133,7 +133,7 @@ pub fn alli<A:Copy + Owned>(
}
/// Returns true if the function holds for any elements in the vector.
pub fn any<A:Copy + Owned>(
pub fn any<A:Copy + Send>(
xs: &[A],
fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
let mapped = map_slices(xs, || {

View file

@ -13,10 +13,10 @@
/** Task-local reference counted smart pointers
Task-local reference counted smart pointers are an alternative to managed boxes with deterministic
destruction. They are restricted to containing types that are either `Owned` or `Freeze` (or both) to
destruction. They are restricted to containing types that are either `Send` or `Freeze` (or both) to
prevent cycles.
Neither `Rc<T>` or `RcMut<T>` is ever `Owned` and `RcMut<T>` is never `Freeze`. If `T` is `Freeze`, a
Neither `Rc<T>` or `RcMut<T>` is ever `Send` and `RcMut<T>` is never `Freeze`. If `T` is `Freeze`, a
cycle cannot be created with `Rc<T>` because there is no way to modify it after creation.
*/
@ -51,7 +51,7 @@ impl<T> Rc<T> {
}
// FIXME: #6516: should be a static method
pub fn rc_from_owned<T: Owned>(value: T) -> Rc<T> {
pub fn rc_from_owned<T: Send>(value: T) -> Rc<T> {
unsafe { Rc::new(value) }
}
@ -185,7 +185,7 @@ impl<T> RcMut<T> {
}
// FIXME: #6516: should be a static method
pub fn rc_mut_from_owned<T: Owned>(value: T) -> RcMut<T> {
pub fn rc_mut_from_owned<T: Send>(value: T) -> RcMut<T> {
unsafe { RcMut::new(value) }
}

View file

@ -86,7 +86,7 @@ struct SemInner<Q> {
struct Sem<Q>(Exclusive<SemInner<Q>>);
#[doc(hidden)]
fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> {
fn new_sem<Q:Send>(count: int, q: Q) -> Sem<Q> {
Sem(exclusive(SemInner {
count: count, waiters: new_waitqueue(), blocked: q }))
}
@ -101,7 +101,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
}
#[doc(hidden)]
impl<Q:Owned> Sem<Q> {
impl<Q:Send> Sem<Q> {
pub fn acquire(&self) {
unsafe {
let mut waiter_nobe = None;
@ -175,7 +175,7 @@ struct SemReleaseGeneric<'self, Q> { sem: &'self Sem<Q> }
#[doc(hidden)]
#[unsafe_destructor]
impl<'self, Q:Owned> Drop for SemReleaseGeneric<'self, Q> {
impl<'self, Q:Send> Drop for SemReleaseGeneric<'self, Q> {
fn drop(&self) {
self.sem.release();
}

View file

@ -39,7 +39,7 @@ use core::libc;
* * ch - a channel of type T to send a `val` on
* * val - a value of type T to send over the provided `ch`
*/
pub fn delayed_send<T:Owned>(iotask: &IoTask,
pub fn delayed_send<T:Send>(iotask: &IoTask,
msecs: uint,
ch: &Chan<T>,
val: T) {
@ -119,7 +119,7 @@ pub fn sleep(iotask: &IoTask, msecs: uint) {
* on the provided port in the allotted timeout period, then the result will
* be a `Some(T)`. If not, then `None` will be returned.
*/
pub fn recv_timeout<T:Copy + Owned>(iotask: &IoTask,
pub fn recv_timeout<T:Copy + Send>(iotask: &IoTask,
msecs: uint,
wait_po: &Port<T>)
-> Option<T> {

View file

@ -272,7 +272,7 @@ impl Context {
}
}
pub fn prep<T:Owned +
pub fn prep<T:Send +
Encodable<json::Encoder> +
Decodable<json::Decoder>>(@self, // FIXME(#5121)
fn_name:&str,
@ -292,7 +292,7 @@ trait TPrep {
fn declare_input(&mut self, kind:&str, name:&str, val:&str);
fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool;
fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool;
fn exec<T:Owned +
fn exec<T:Send +
Encodable<json::Encoder> +
Decodable<json::Decoder>>( // FIXME(#5121)
&self, blk: ~fn(&Exec) -> T) -> Work<T>;
@ -328,7 +328,7 @@ impl TPrep for Prep {
return true;
}
fn exec<T:Owned +
fn exec<T:Send +
Encodable<json::Encoder> +
Decodable<json::Decoder>>( // FIXME(#5121)
&self, blk: ~fn(&Exec) -> T) -> Work<T> {
@ -365,7 +365,7 @@ impl TPrep for Prep {
}
}
impl<T:Owned +
impl<T:Send +
Encodable<json::Encoder> +
Decodable<json::Decoder>> Work<T> { // FIXME(#5121)
pub fn new(p: @mut Prep, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
@ -374,7 +374,7 @@ impl<T:Owned +
}
// FIXME (#3724): movable self. This should be in impl Work.
fn unwrap<T:Owned +
fn unwrap<T:Send +
Encodable<json::Encoder> +
Decodable<json::Decoder>>( // FIXME(#5121)
w: Work<T>) -> T {

View file

@ -359,7 +359,7 @@ of its owner:
LIFETIME(LV.f, LT, MQ) // L-Field
LIFETIME(LV, LT, MQ)
LIFETIME(*LV, LT, MQ) // L-Deref-Owned
LIFETIME(*LV, LT, MQ) // L-Deref-Send
TYPE(LV) = ~Ty
LIFETIME(LV, LT, MQ)
@ -504,7 +504,7 @@ must prevent the owned pointer `LV` from being mutated, which means
that we always add `MUTATE` and `CLAIM` to the restriction set imposed
on `LV`:
RESTRICTIONS(*LV, ACTIONS) = RS, (*LV, ACTIONS) // R-Deref-Owned-Pointer
RESTRICTIONS(*LV, ACTIONS) = RS, (*LV, ACTIONS) // R-Deref-Send-Pointer
TYPE(LV) = ~Ty
RESTRICTIONS(LV, ACTIONS|MUTATE|CLAIM) = RS

View file

@ -109,7 +109,7 @@ impl GuaranteeLifetimeContext {
}
mc::cat_downcast(base) |
mc::cat_deref(base, _, mc::uniq_ptr(*)) | // L-Deref-Owned
mc::cat_deref(base, _, mc::uniq_ptr(*)) | // L-Deref-Send
mc::cat_interior(base, _) => { // L-Field
self.check(base, discr_scope)
}

View file

@ -103,7 +103,7 @@ impl RestrictionsContext {
}
mc::cat_deref(cmt_base, _, mc::uniq_ptr(*)) => {
// R-Deref-Owned-Pointer
// R-Deref-Send-Pointer
//
// When we borrow the interior of an owned pointer, we
// cannot permit the base to be mutated, because that

View file

@ -538,7 +538,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
check_pointer_pat(pcx, Managed, inner, pat.id, pat.span, expected);
}
ast::pat_uniq(inner) => {
check_pointer_pat(pcx, Owned, inner, pat.id, pat.span, expected);
check_pointer_pat(pcx, Send, inner, pat.id, pat.span, expected);
}
ast::pat_region(inner) => {
check_pointer_pat(pcx, Borrowed, inner, pat.id, pat.span, expected);
@ -624,7 +624,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt,
ty::ty_box(e_inner) if pointer_kind == Managed => {
check_inner(e_inner);
}
ty::ty_uniq(e_inner) if pointer_kind == Owned => {
ty::ty_uniq(e_inner) if pointer_kind == Send => {
check_inner(e_inner);
}
ty::ty_rptr(_, e_inner) if pointer_kind == Borrowed => {
@ -641,7 +641,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt,
Some(expected),
fmt!("%s pattern", match pointer_kind {
Managed => "an @-box",
Owned => "a ~-box",
Send => "a ~-box",
Borrowed => "an &-pointer"
}),
None);
@ -651,4 +651,4 @@ pub fn check_pointer_pat(pcx: &pat_ctxt,
}
#[deriving(Eq)]
enum PointerKind { Managed, Owned, Borrowed }
enum PointerKind { Managed, Send, Borrowed }

View file

@ -99,7 +99,7 @@ fn act(po: &Port<Msg>, source: @str, parse: Parser) {
}
}
pub fn exec<T:Owned>(
pub fn exec<T:Send>(
srv: Srv,
f: ~fn(ctxt: Ctxt) -> T
) -> T {

View file

@ -101,7 +101,7 @@ fn fold_item(
}
}
fn parse_item_attrs<T:Owned>(
fn parse_item_attrs<T:Send>(
srv: astsrv::Srv,
id: doc::AstId,
parse_attrs: ~fn(a: ~[ast::attribute]) -> T) -> T {

View file

@ -112,7 +112,7 @@ impl<T: DeepClone> DeepClone for ~T {
fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
}
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
impl<T: Freeze + DeepClone> DeepClone for @T {
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
@ -120,7 +120,7 @@ impl<T: Freeze + DeepClone> DeepClone for @T {
fn deep_clone(&self) -> @T { @(**self).deep_clone() }
}
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
impl<T: Freeze + DeepClone> DeepClone for @mut T {
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.

View file

@ -17,7 +17,7 @@ Message passing
use cast::{transmute, transmute_mut};
use container::Container;
use either::{Either, Left, Right};
use kinds::Owned;
use kinds::Send;
use option::{Option, Some, None};
use uint;
use vec::OwnedVector;
@ -77,7 +77,7 @@ pub struct Port<T> {
These allow sending or receiving an unlimited number of messages.
*/
pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
let (port, chan) = match rt::context() {
rt::OldTaskContext => match pipesy::stream() {
(p, c) => (Left(p), Left(c))
@ -91,7 +91,7 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
return (port, chan);
}
impl<T: Owned> GenericChan<T> for Chan<T> {
impl<T: Send> GenericChan<T> for Chan<T> {
fn send(&self, x: T) {
match self.inner {
Left(ref chan) => chan.send(x),
@ -100,7 +100,7 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
}
}
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
impl<T: Send> GenericSmartChan<T> for Chan<T> {
fn try_send(&self, x: T) -> bool {
match self.inner {
Left(ref chan) => chan.try_send(x),
@ -109,7 +109,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
}
}
impl<T: Owned> GenericPort<T> for Port<T> {
impl<T: Send> GenericPort<T> for Port<T> {
fn recv(&self) -> T {
match self.inner {
Left(ref port) => port.recv(),
@ -125,7 +125,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
}
}
impl<T: Owned> Peekable<T> for Port<T> {
impl<T: Send> Peekable<T> for Port<T> {
fn peek(&self) -> bool {
match self.inner {
Left(ref port) => port.peek(),
@ -134,7 +134,7 @@ impl<T: Owned> Peekable<T> for Port<T> {
}
}
impl<T: Owned> Selectable for Port<T> {
impl<T: Send> Selectable for Port<T> {
fn header(&mut self) -> *mut PacketHeader {
match self.inner {
Left(ref mut port) => port.header(),
@ -149,7 +149,7 @@ pub struct PortSet<T> {
ports: ~[pipesy::Port<T>],
}
impl<T: Owned> PortSet<T> {
impl<T: Send> PortSet<T> {
pub fn new() -> PortSet<T> {
PortSet {
ports: ~[]
@ -175,7 +175,7 @@ impl<T: Owned> PortSet<T> {
}
}
impl<T:Owned> GenericPort<T> for PortSet<T> {
impl<T:Send> GenericPort<T> for PortSet<T> {
fn try_recv(&self) -> Option<T> {
unsafe {
let self_ports = transmute_mut(&self.ports);
@ -204,7 +204,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
}
}
impl<T: Owned> Peekable<T> for PortSet<T> {
impl<T: Send> Peekable<T> for PortSet<T> {
fn peek(&self) -> bool {
// It'd be nice to use self.port.each, but that version isn't
// pure.
@ -223,7 +223,7 @@ pub struct SharedChan<T> {
ch: Exclusive<pipesy::Chan<T>>
}
impl<T: Owned> SharedChan<T> {
impl<T: Send> SharedChan<T> {
/// Converts a `chan` into a `shared_chan`.
pub fn new(c: Chan<T>) -> SharedChan<T> {
let Chan { inner } = c;
@ -235,7 +235,7 @@ impl<T: Owned> SharedChan<T> {
}
}
impl<T: Owned> GenericChan<T> for SharedChan<T> {
impl<T: Send> GenericChan<T> for SharedChan<T> {
fn send(&self, x: T) {
unsafe {
let mut xx = Some(x);
@ -247,7 +247,7 @@ impl<T: Owned> GenericChan<T> for SharedChan<T> {
}
}
impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
impl<T: Send> GenericSmartChan<T> for SharedChan<T> {
fn try_send(&self, x: T) -> bool {
unsafe {
let mut xx = Some(x);
@ -259,7 +259,7 @@ impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
}
}
impl<T: Owned> ::clone::Clone for SharedChan<T> {
impl<T: Send> ::clone::Clone for SharedChan<T> {
fn clone(&self) -> SharedChan<T> {
SharedChan { ch: self.ch.clone() }
}
@ -273,7 +273,7 @@ pub struct ChanOne<T> {
inner: Either<pipesy::ChanOne<T>, rtcomm::ChanOne<T>>
}
pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
pub fn oneshot<T: Send>() -> (PortOne<T>, ChanOne<T>) {
let (port, chan) = match rt::context() {
rt::OldTaskContext => match pipesy::oneshot() {
(p, c) => (Left(p), Left(c)),
@ -287,7 +287,7 @@ pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
return (port, chan);
}
impl<T: Owned> PortOne<T> {
impl<T: Send> PortOne<T> {
pub fn recv(self) -> T {
let PortOne { inner } = self;
match inner {
@ -305,7 +305,7 @@ impl<T: Owned> PortOne<T> {
}
}
impl<T: Owned> ChanOne<T> {
impl<T: Send> ChanOne<T> {
pub fn send(self, data: T) {
let ChanOne { inner } = self;
match inner {
@ -323,7 +323,7 @@ impl<T: Owned> ChanOne<T> {
}
}
pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
pub fn recv_one<T: Send>(port: PortOne<T>) -> T {
let PortOne { inner } = port;
match inner {
Left(p) => pipesy::recv_one(p),
@ -331,7 +331,7 @@ pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
}
}
pub fn try_recv_one<T: Owned>(port: PortOne<T>) -> Option<T> {
pub fn try_recv_one<T: Send>(port: PortOne<T>) -> Option<T> {
let PortOne { inner } = port;
match inner {
Left(p) => pipesy::try_recv_one(p),
@ -339,7 +339,7 @@ pub fn try_recv_one<T: Owned>(port: PortOne<T>) -> Option<T> {
}
}
pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) {
let ChanOne { inner } = chan;
match inner {
Left(c) => pipesy::send_one(c, data),
@ -347,7 +347,7 @@ pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
}
}
pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) -> bool {
pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T) -> bool {
let ChanOne { inner } = chan;
match inner {
Left(c) => pipesy::try_send_one(c, data),
@ -357,7 +357,7 @@ pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) -> bool {
mod pipesy {
use kinds::Owned;
use kinds::Send;
use option::{Option, Some, None};
use pipes::{recv, try_recv, peek, PacketHeader};
use super::{GenericChan, GenericSmartChan, GenericPort, Peekable, Selectable};
@ -365,17 +365,17 @@ mod pipesy {
use util::replace;
/*proto! oneshot (
Oneshot:send<T:Owned> {
Oneshot:send<T:Send> {
send(T) -> !
}
)*/
#[allow(non_camel_case_types)]
pub mod oneshot {
priv use core::kinds::Owned;
priv use core::kinds::Send;
use ptr::to_mut_unsafe_ptr;
pub fn init<T: Owned>() -> (server::Oneshot<T>, client::Oneshot<T>) {
pub fn init<T: Send>() -> (server::Oneshot<T>, client::Oneshot<T>) {
pub use core::pipes::HasBuffer;
let buffer = ~::core::pipes::Buffer {
@ -399,10 +399,10 @@ mod pipesy {
#[allow(non_camel_case_types)]
pub mod client {
priv use core::kinds::Owned;
priv use core::kinds::Send;
#[allow(non_camel_case_types)]
pub fn try_send<T: Owned>(pipe: Oneshot<T>, x_0: T) ->
pub fn try_send<T: Send>(pipe: Oneshot<T>, x_0: T) ->
::core::option::Option<()> {
{
use super::send;
@ -414,7 +414,7 @@ mod pipesy {
}
#[allow(non_camel_case_types)]
pub fn send<T: Owned>(pipe: Oneshot<T>, x_0: T) {
pub fn send<T: Send>(pipe: Oneshot<T>, x_0: T) {
{
use super::send;
let message = send(x_0);
@ -464,12 +464,12 @@ mod pipesy {
}
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
pub fn oneshot<T: Send>() -> (PortOne<T>, ChanOne<T>) {
let (port, chan) = oneshot::init();
(PortOne::new(port), ChanOne::new(chan))
}
impl<T: Owned> PortOne<T> {
impl<T: Send> PortOne<T> {
pub fn recv(self) -> T { recv_one(self) }
pub fn try_recv(self) -> Option<T> { try_recv_one(self) }
pub fn unwrap(self) -> oneshot::server::Oneshot<T> {
@ -479,7 +479,7 @@ mod pipesy {
}
}
impl<T: Owned> ChanOne<T> {
impl<T: Send> ChanOne<T> {
pub fn send(self, data: T) { send_one(self, data) }
pub fn try_send(self, data: T) -> bool { try_send_one(self, data) }
pub fn unwrap(self) -> oneshot::client::Oneshot<T> {
@ -493,7 +493,7 @@ mod pipesy {
* Receive a message from a oneshot pipe, failing if the connection was
* closed.
*/
pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
pub fn recv_one<T: Send>(port: PortOne<T>) -> T {
match port {
PortOne { contents: port } => {
let oneshot::send(message) = recv(port);
@ -503,7 +503,7 @@ mod pipesy {
}
/// Receive a message from a oneshot pipe unless the connection was closed.
pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {
pub fn try_recv_one<T: Send> (port: PortOne<T>) -> Option<T> {
match port {
PortOne { contents: port } => {
let message = try_recv(port);
@ -519,7 +519,7 @@ mod pipesy {
}
/// Send a message on a oneshot pipe, failing if the connection was closed.
pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) {
match chan {
ChanOne { contents: chan } => oneshot::client::send(chan, data),
}
@ -529,7 +529,7 @@ mod pipesy {
* Send a message on a oneshot pipe, or return false if the connection was
* closed.
*/
pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) -> bool {
pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T) -> bool {
match chan {
ChanOne { contents: chan } => {
oneshot::client::try_send(chan, data).is_some()
@ -540,16 +540,16 @@ mod pipesy {
// Streams - Make pipes a little easier in general.
/*proto! streamp (
Open:send<T: Owned> {
Open:send<T: Send> {
data(T) -> Open<T>
}
)*/
#[allow(non_camel_case_types)]
pub mod streamp {
priv use core::kinds::Owned;
priv use core::kinds::Send;
pub fn init<T: Owned>() -> (server::Open<T>, client::Open<T>) {
pub fn init<T: Send>() -> (server::Open<T>, client::Open<T>) {
pub use core::pipes::HasBuffer;
::core::pipes::entangle()
}
@ -559,10 +559,10 @@ mod pipesy {
#[allow(non_camel_case_types)]
pub mod client {
priv use core::kinds::Owned;
priv use core::kinds::Send;
#[allow(non_camel_case_types)]
pub fn try_data<T: Owned>(pipe: Open<T>, x_0: T) ->
pub fn try_data<T: Send>(pipe: Open<T>, x_0: T) ->
::core::option::Option<Open<T>> {
{
use super::data;
@ -575,7 +575,7 @@ mod pipesy {
}
#[allow(non_camel_case_types)]
pub fn data<T: Owned>(pipe: Open<T>, x_0: T) -> Open<T> {
pub fn data<T: Send>(pipe: Open<T>, x_0: T) -> Open<T> {
{
use super::data;
let (s, c) = ::core::pipes::entangle();
@ -613,7 +613,7 @@ mod pipesy {
These allow sending or receiving an unlimited number of messages.
*/
pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
let (s, c) = streamp::init();
(Port {
@ -623,7 +623,7 @@ mod pipesy {
})
}
impl<T: Owned> GenericChan<T> for Chan<T> {
impl<T: Send> GenericChan<T> for Chan<T> {
#[inline]
fn send(&self, x: T) {
unsafe {
@ -634,7 +634,7 @@ mod pipesy {
}
}
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
impl<T: Send> GenericSmartChan<T> for Chan<T> {
#[inline]
fn try_send(&self, x: T) -> bool {
unsafe {
@ -651,7 +651,7 @@ mod pipesy {
}
}
impl<T: Owned> GenericPort<T> for Port<T> {
impl<T: Send> GenericPort<T> for Port<T> {
#[inline]
fn recv(&self) -> T {
unsafe {
@ -679,7 +679,7 @@ mod pipesy {
}
}
impl<T: Owned> Peekable<T> for Port<T> {
impl<T: Send> Peekable<T> for Port<T> {
#[inline]
fn peek(&self) -> bool {
unsafe {
@ -695,7 +695,7 @@ mod pipesy {
}
}
impl<T: Owned> Selectable for Port<T> {
impl<T: Send> Selectable for Port<T> {
fn header(&mut self) -> *mut PacketHeader {
match self.endp {
Some(ref mut endp) => endp.header(),
@ -723,15 +723,15 @@ pub fn select2i<A:Selectable, B:Selectable>(a: &mut A, b: &mut B)
}
/// Receive a message from one of two endpoints.
pub trait Select2<T: Owned, U: Owned> {
pub trait Select2<T: Send, U: Send> {
/// Receive a message or return `None` if a connection closes.
fn try_select(&mut self) -> Either<Option<T>, Option<U>>;
/// Receive a message or fail if a connection closes.
fn select(&mut self) -> Either<T, U>;
}
impl<T:Owned,
U:Owned,
impl<T:Send,
U:Send,
Left:Selectable + GenericPort<T>,
Right:Selectable + GenericPort<U>>
Select2<T, U>

View file

@ -24,7 +24,7 @@ The 4 kinds are
scalar types and managed pointers, and exludes owned pointers. It
also excludes types that implement `Drop`.
* Owned - owned types and types containing owned types. These types
* Send - owned types and types containing owned types. These types
may be transferred across task boundaries.
* Freeze - types that are deeply immutable.
@ -45,13 +45,13 @@ pub trait Copy {
#[cfg(stage0)]
#[lang="owned"]
pub trait Owned {
pub trait Send {
// empty.
}
#[cfg(not(stage0))]
#[lang="send"]
pub trait Owned {
pub trait Send {
// empty.
}

View file

@ -88,7 +88,7 @@ use container::Container;
use cast::{forget, transmute, transmute_copy, transmute_mut};
use either::{Either, Left, Right};
use iterator::IteratorUtil;
use kinds::Owned;
use kinds::Send;
use libc;
use ops::Drop;
use option::{None, Option, Some};
@ -177,7 +177,7 @@ impl PacketHeader {
transmute_copy(&self.buffer)
}
pub fn set_buffer<T:Owned>(&mut self, b: ~Buffer<T>) {
pub fn set_buffer<T:Send>(&mut self, b: ~Buffer<T>) {
unsafe {
self.buffer = transmute_copy(&b);
}
@ -193,13 +193,13 @@ pub trait HasBuffer {
fn set_buffer(&mut self, b: *libc::c_void);
}
impl<T:Owned> HasBuffer for Packet<T> {
impl<T:Send> HasBuffer for Packet<T> {
fn set_buffer(&mut self, b: *libc::c_void) {
self.header.buffer = b;
}
}
pub fn mk_packet<T:Owned>() -> Packet<T> {
pub fn mk_packet<T:Send>() -> Packet<T> {
Packet {
header: PacketHeader(),
payload: None,
@ -230,7 +230,7 @@ pub fn packet<T>() -> *mut Packet<T> {
p
}
pub fn entangle_buffer<T:Owned,Tstart:Owned>(
pub fn entangle_buffer<T:Send,Tstart:Send>(
mut buffer: ~Buffer<T>,
init: &fn(*libc::c_void, x: &mut T) -> *mut Packet<Tstart>)
-> (RecvPacketBuffered<Tstart, T>, SendPacketBuffered<Tstart, T>) {
@ -396,7 +396,7 @@ pub fn send<T,Tbuffer>(mut p: SendPacketBuffered<T,Tbuffer>,
Fails if the sender closes the connection.
*/
pub fn recv<T:Owned,Tbuffer:Owned>(
pub fn recv<T:Send,Tbuffer:Send>(
p: RecvPacketBuffered<T, Tbuffer>) -> T {
try_recv(p).expect("connection closed")
}
@ -407,7 +407,7 @@ Returns `None` if the sender has closed the connection without sending
a message, or `Some(T)` if a message was received.
*/
pub fn try_recv<T:Owned,Tbuffer:Owned>(mut p: RecvPacketBuffered<T, Tbuffer>)
pub fn try_recv<T:Send,Tbuffer:Send>(mut p: RecvPacketBuffered<T, Tbuffer>)
-> Option<T> {
let p_ = p.unwrap();
let p = unsafe { &mut *p_ };
@ -427,7 +427,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(mut p: RecvPacketBuffered<T, Tbuffer>)
}
}
fn try_recv_<T:Owned>(p: &mut Packet<T>) -> Option<T> {
fn try_recv_<T:Send>(p: &mut Packet<T>) -> Option<T> {
// optimistic path
match p.header.state {
Full => {
@ -511,7 +511,7 @@ fn try_recv_<T:Owned>(p: &mut Packet<T>) -> Option<T> {
}
/// Returns true if messages are available.
pub fn peek<T:Owned,Tb:Owned>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
pub fn peek<T:Send,Tb:Send>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
unsafe {
match (*p.header()).state {
Empty | Terminated => false,
@ -521,7 +521,7 @@ pub fn peek<T:Owned,Tb:Owned>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
}
}
fn sender_terminate<T:Owned>(p: *mut Packet<T>) {
fn sender_terminate<T:Send>(p: *mut Packet<T>) {
let p = unsafe {
&mut *p
};
@ -553,7 +553,7 @@ fn sender_terminate<T:Owned>(p: *mut Packet<T>) {
}
}
fn receiver_terminate<T:Owned>(p: *mut Packet<T>) {
fn receiver_terminate<T:Send>(p: *mut Packet<T>) {
let p = unsafe {
&mut *p
};
@ -671,7 +671,7 @@ pub struct SendPacketBuffered<T, Tbuffer> {
}
#[unsafe_destructor]
impl<T:Owned,Tbuffer:Owned> Drop for SendPacketBuffered<T,Tbuffer> {
impl<T:Send,Tbuffer:Send> Drop for SendPacketBuffered<T,Tbuffer> {
fn drop(&self) {
unsafe {
let this: &mut SendPacketBuffered<T,Tbuffer> = transmute(self);
@ -729,7 +729,7 @@ pub struct RecvPacketBuffered<T, Tbuffer> {
}
#[unsafe_destructor]
impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> {
impl<T:Send,Tbuffer:Send> Drop for RecvPacketBuffered<T,Tbuffer> {
fn drop(&self) {
unsafe {
let this: &mut RecvPacketBuffered<T,Tbuffer> = transmute(self);
@ -741,7 +741,7 @@ impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> {
}
}
impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
impl<T:Send,Tbuffer:Send> RecvPacketBuffered<T, Tbuffer> {
pub fn unwrap(&mut self) -> *mut Packet<T> {
replace(&mut self.p, None).unwrap()
}
@ -751,7 +751,7 @@ impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
}
}
impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
impl<T:Send,Tbuffer:Send> Selectable for RecvPacketBuffered<T, Tbuffer> {
fn header(&mut self) -> *mut PacketHeader {
match self.p {
Some(packet) => unsafe {
@ -807,7 +807,7 @@ Sometimes messages will be available on both endpoints at once. In
this case, `select2` may return either `left` or `right`.
*/
pub fn select2<A:Owned,Ab:Owned,B:Owned,Bb:Owned>(
pub fn select2<A:Send,Ab:Send,B:Send,Bb:Send>(
mut a: RecvPacketBuffered<A, Ab>,
mut b: RecvPacketBuffered<B, Bb>)
-> Either<(Option<A>, RecvPacketBuffered<B, Bb>),
@ -847,7 +847,7 @@ pub fn select2i<A:Selectable,B:Selectable>(a: &mut A, b: &mut B)
/// Waits on a set of endpoints. Returns a message, its index, and a
/// list of the remaining endpoints.
pub fn select<T:Owned,Tb:Owned>(mut endpoints: ~[RecvPacketBuffered<T, Tb>])
pub fn select<T:Send,Tb:Send>(mut endpoints: ~[RecvPacketBuffered<T, Tb>])
-> (uint,
Option<T>,
~[RecvPacketBuffered<T, Tb>]) {

View file

@ -30,7 +30,7 @@ Rust's prelude has three main parts:
// Reexported core operators
pub use either::{Either, Left, Right};
pub use kinds::{Copy, Sized};
pub use kinds::{Freeze, Owned};
pub use kinds::{Freeze, Send};
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Drop};

View file

@ -19,7 +19,7 @@ use option::*;
use cast;
use util;
use ops::Drop;
use kinds::Owned;
use kinds::Send;
use rt::sched::{Scheduler, Coroutine};
use rt::local::Local;
use unstable::intrinsics::{atomic_xchg, atomic_load};
@ -68,7 +68,7 @@ pub struct PortOneHack<T> {
suppress_finalize: bool
}
pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
pub fn oneshot<T: Send>() -> (PortOne<T>, ChanOne<T>) {
let packet: ~Packet<T> = ~Packet {
state: STATE_BOTH,
payload: None
@ -307,20 +307,20 @@ pub struct Port<T> {
next: Cell<PortOne<StreamPayload<T>>>
}
pub fn stream<T: Owned>() -> (Port<T>, Chan<T>) {
pub fn stream<T: Send>() -> (Port<T>, Chan<T>) {
let (pone, cone) = oneshot();
let port = Port { next: Cell::new(pone) };
let chan = Chan { next: Cell::new(cone) };
return (port, chan);
}
impl<T: Owned> GenericChan<T> for Chan<T> {
impl<T: Send> GenericChan<T> for Chan<T> {
fn send(&self, val: T) {
self.try_send(val);
}
}
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
impl<T: Send> GenericSmartChan<T> for Chan<T> {
fn try_send(&self, val: T) -> bool {
let (next_pone, next_cone) = oneshot();
let cone = self.next.take();

View file

@ -9,7 +9,7 @@
// except according to those terms.
use container::Container;
use kinds::Owned;
use kinds::Send;
use vec::OwnedVector;
use cell::Cell;
use option::*;
@ -21,7 +21,7 @@ pub struct MessageQueue<T> {
priv queue: ~Exclusive<~[T]>
}
impl<T: Owned> MessageQueue<T> {
impl<T: Send> MessageQueue<T> {
pub fn new() -> MessageQueue<T> {
MessageQueue {
queue: ~exclusive(~[])

View file

@ -13,7 +13,7 @@ use option::*;
use vec::OwnedVector;
use unstable::sync::{Exclusive, exclusive};
use cell::Cell;
use kinds::Owned;
use kinds::Send;
use clone::Clone;
pub struct WorkQueue<T> {
@ -21,7 +21,7 @@ pub struct WorkQueue<T> {
priv queue: ~Exclusive<~[T]>
}
impl<T: Owned> WorkQueue<T> {
impl<T: Send> WorkQueue<T> {
pub fn new() -> WorkQueue<T> {
WorkQueue {
queue: ~exclusive(~[])

View file

@ -353,7 +353,7 @@ impl TaskBuilder {
}
/// Runs a task, while transfering ownership of one argument to the child.
pub fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) {
pub fn spawn_with<A:Send>(&mut self, arg: A, f: ~fn(v: A)) {
let arg = Cell::new(arg);
do self.spawn {
f(arg.take());
@ -373,7 +373,7 @@ impl TaskBuilder {
* # Failure
* Fails if a future_result was already set for this task.
*/
pub fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> {
pub fn try<T:Send>(&mut self, f: ~fn() -> T) -> Result<T,()> {
let (po, ch) = stream::<T>();
let mut result = None;
@ -445,7 +445,7 @@ pub fn spawn_supervised(f: ~fn()) {
task.spawn(f)
}
pub fn spawn_with<A:Owned>(arg: A, f: ~fn(v: A)) {
pub fn spawn_with<A:Send>(arg: A, f: ~fn(v: A)) {
/*!
* Runs a task, while transfering ownership of one argument to the
* child.
@ -478,7 +478,7 @@ pub fn spawn_sched(mode: SchedMode, f: ~fn()) {
task.spawn(f)
}
pub fn try<T:Owned>(f: ~fn() -> T) -> Result<T,()> {
pub fn try<T:Send>(f: ~fn() -> T) -> Result<T,()> {
/*!
* Execute a function in another task and return either the return value
* of the function or result::err.

View file

@ -27,7 +27,7 @@ avoid hitting the mutex.
use cast::{transmute};
use clone::Clone;
use kinds::Owned;
use kinds::Send;
use libc::{c_void};
use option::{Option, Some, None};
use ops::Drop;
@ -43,7 +43,7 @@ use sys::Closure;
pub type GlobalDataKey<'self,T> = &'self fn(v: T);
pub unsafe fn global_data_clone_create<T:Owned + Clone>(
pub unsafe fn global_data_clone_create<T:Send + Clone>(
key: GlobalDataKey<T>, create: &fn() -> ~T) -> T {
/*!
* Clone a global value or, if it has not been created,
@ -59,7 +59,7 @@ pub unsafe fn global_data_clone_create<T:Owned + Clone>(
global_data_clone_create_(key_ptr(key), create)
}
unsafe fn global_data_clone_create_<T:Owned + Clone>(
unsafe fn global_data_clone_create_<T:Send + Clone>(
key: uint, create: &fn() -> ~T) -> T {
let mut clone_value: Option<T> = None;
@ -79,13 +79,13 @@ unsafe fn global_data_clone_create_<T:Owned + Clone>(
return clone_value.unwrap();
}
unsafe fn global_data_modify<T:Owned>(
unsafe fn global_data_modify<T:Send>(
key: GlobalDataKey<T>, op: &fn(Option<~T>) -> Option<~T>) {
global_data_modify_(key_ptr(key), op)
}
unsafe fn global_data_modify_<T:Owned>(
unsafe fn global_data_modify_<T:Send>(
key: uint, op: &fn(Option<~T>) -> Option<~T>) {
let mut old_dtor = None;
@ -124,7 +124,7 @@ unsafe fn global_data_modify_<T:Owned>(
}
}
pub unsafe fn global_data_clone<T:Owned + Clone>(
pub unsafe fn global_data_clone<T:Send + Clone>(
key: GlobalDataKey<T>) -> Option<T> {
let mut maybe_clone: Option<T> = None;
do global_data_modify(key) |current| {
@ -220,7 +220,7 @@ fn get_global_state() -> Exclusive<GlobalState> {
}
}
fn key_ptr<T:Owned>(key: GlobalDataKey<T>) -> uint {
fn key_ptr<T:Send>(key: GlobalDataKey<T>) -> uint {
unsafe {
let closure: Closure = transmute(key);
return transmute(closure.code);

View file

@ -17,7 +17,7 @@ use unstable::finally::Finally;
use unstable::intrinsics;
use ops::Drop;
use clone::Clone;
use kinds::Owned;
use kinds::Send;
/// An atomically reference counted pointer.
///
@ -31,7 +31,7 @@ struct AtomicRcBoxData<T> {
data: Option<T>,
}
impl<T: Owned> UnsafeAtomicRcBox<T> {
impl<T: Send> UnsafeAtomicRcBox<T> {
pub fn new(data: T) -> UnsafeAtomicRcBox<T> {
unsafe {
let data = ~AtomicRcBoxData { count: 1, data: Some(data) };
@ -61,7 +61,7 @@ impl<T: Owned> UnsafeAtomicRcBox<T> {
}
}
impl<T: Owned> Clone for UnsafeAtomicRcBox<T> {
impl<T: Send> Clone for UnsafeAtomicRcBox<T> {
fn clone(&self) -> UnsafeAtomicRcBox<T> {
unsafe {
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
@ -144,7 +144,7 @@ pub struct Exclusive<T> {
x: UnsafeAtomicRcBox<ExData<T>>
}
pub fn exclusive<T:Owned>(user_data: T) -> Exclusive<T> {
pub fn exclusive<T:Send>(user_data: T) -> Exclusive<T> {
let data = ExData {
lock: LittleLock(),
failed: false,
@ -155,14 +155,14 @@ pub fn exclusive<T:Owned>(user_data: T) -> Exclusive<T> {
}
}
impl<T:Owned> Clone for Exclusive<T> {
impl<T:Send> Clone for Exclusive<T> {
// Duplicate an exclusive ARC, as std::arc::clone.
fn clone(&self) -> Exclusive<T> {
Exclusive { x: self.x.clone() }
}
}
impl<T:Owned> Exclusive<T> {
impl<T:Send> Exclusive<T> {
// Exactly like std::arc::mutex_arc,access(), but with the little_lock
// instead of a proper mutex. Same reason for being unsafe.
//

View file

@ -147,7 +147,7 @@ pub static crate_node_id: node_id = 0;
// The AST represents all type param bounds as types.
// typeck::collect::compute_bounds matches these against
// the "special" built-in traits (see middle::lang_items) and
// detects Copy, Send, Owned, and Freeze.
// detects Copy, Send, Send, and Freeze.
pub enum TyParamBound {
TraitTyParamBound(@trait_ref),
RegionTyParamBound

View file

@ -30,7 +30,7 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt,
generics: LifetimeBounds::empty(),
explicit_self: borrowed_explicit_self(),
args: ~[],
ret_ty: Ptr(~Literal(Path::new_local("str")), Owned),
ret_ty: Ptr(~Literal(Path::new_local("str")), Send),
const_nonmatching: false,
combine_substructure: to_str_substructure
}

View file

@ -22,7 +22,7 @@ use opt_vec;
/// The types of pointers
pub enum PtrTy<'self> {
Owned, // ~
Send, // ~
Managed(ast::mutability), // @[mut]
Borrowed(Option<&'self str>, ast::mutability), // &['lifetime] [mut]
}
@ -128,7 +128,7 @@ impl<'self> Ty<'self> {
Ptr(ref ty, ref ptr) => {
let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);
match *ptr {
Owned => {
Send => {
cx.ty_uniq(span, raw_ty)
}
Managed(mutbl) => {
@ -248,7 +248,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
let self_ty = respan(
span,
match *ptr {
Owned => ast::sty_uniq(ast::m_imm),
Send => ast::sty_uniq(ast::m_imm),
Managed(mutbl) => ast::sty_box(mutbl),
Borrowed(ref lt, mutbl) => {
let lt = lt.map(|s| @cx.lifetime(span,

View file

@ -11,7 +11,7 @@
use std::comm::*;
use std::task;
pub fn foo<T:Owned + Copy>(x: T) -> Port<T> {
pub fn foo<T:Send + Copy>(x: T) -> Port<T> {
let (p, c) = stream();
do task::spawn() {
c.send(copy x);

View file

@ -82,7 +82,7 @@ endpoint. The send endpoint is returned to the caller and the receive
endpoint is passed to the new task.
*/
pub fn spawn_service<T:Owned,Tb:Owned>(
pub fn spawn_service<T:Send,Tb:Send>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
service: ~fn(v: RecvPacketBuffered<T, Tb>))
@ -103,7 +103,7 @@ pub fn spawn_service<T:Owned,Tb:Owned>(
receive state.
*/
pub fn spawn_service_recv<T:Owned,Tb:Owned>(
pub fn spawn_service_recv<T:Send,Tb:Send>(
init: extern fn() -> (SendPacketBuffered<T, Tb>,
RecvPacketBuffered<T, Tb>),
service: ~fn(v: SendPacketBuffered<T, Tb>))
@ -120,7 +120,7 @@ pub fn spawn_service_recv<T:Owned,Tb:Owned>(
client
}
fn switch<T:Owned,Tb:Owned,U>(endp: std::pipes::RecvPacketBuffered<T, Tb>,
fn switch<T:Send,Tb:Send,U>(endp: std::pipes::RecvPacketBuffered<T, Tb>,
f: &fn(v: Option<T>) -> U)
-> U {
f(std::pipes::try_recv(endp))

View file

@ -5,7 +5,7 @@ fn take_any(_: &fn:()) {
fn take_copyable(_: &fn:Copy()) {
}
fn take_copyable_owned(_: &fn:Copy+Owned()) {
fn take_copyable_owned(_: &fn:Copy+Send()) {
}
fn take_const_owned(_: &fn:Const+Owned()) {
@ -14,22 +14,22 @@ fn take_const_owned(_: &fn:Const+Owned()) {
fn give_any(f: &fn:()) {
take_any(f);
take_copyable(f); //~ ERROR expected bounds `Copy` but found no bounds
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found no bounds
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found no bounds
}
fn give_copyable(f: &fn:Copy()) {
take_any(f);
take_copyable(f);
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found bounds `Copy`
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Copy`
}
fn give_owned(f: &fn:Owned()) {
fn give_owned(f: &fn:Send()) {
take_any(f);
take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Owned`
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found bounds `Owned`
take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Send`
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Send`
}
fn give_copyable_owned(f: &fn:Copy+Owned()) {
fn give_copyable_owned(f: &fn:Copy+Send()) {
take_any(f);
take_copyable(f);
take_copyable_owned(f);

View file

@ -9,12 +9,12 @@
// except according to those terms.
pub mod stream {
pub enum Stream<T:Owned> { send(T, ::stream::server::Stream<T>), }
pub enum Stream<T:Send> { send(T, ::stream::server::Stream<T>), }
pub mod server {
use std::option;
use std::pipes;
impl<T:Owned> Stream<T> {
impl<T:Send> Stream<T> {
pub fn recv() -> extern fn(v: Stream<T>) -> ::stream::Stream<T> {
// resolve really should report just one error here.
// Change the test case when it changes.
@ -28,7 +28,7 @@ pub mod stream {
}
}
pub type Stream<T:Owned> = pipes::RecvPacket<::stream::Stream<T>>;
pub type Stream<T:Send> = pipes::RecvPacket<::stream::Stream<T>>;
}
}

View file

@ -2,7 +2,7 @@ struct Foo {
f: @mut int,
}
impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is not Owned
impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is not Send
fn drop(&self) {
*self.f = 10;
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn send<T:Owned>(ch: _chan<T>, data: T) {
fn send<T:Send>(ch: _chan<T>, data: T) {
debug!(ch);
debug!(data);
fail!();

View file

@ -11,9 +11,9 @@
#[non_owned]
enum Foo { A }
fn bar<T: Owned>(_: T) {}
fn bar<T: Send>(_: T) {}
fn main() {
let x = A;
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned`
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Send`
}

View file

@ -11,9 +11,9 @@
#[non_owned]
struct Foo { a: int }
fn bar<T: Owned>(_: T) {}
fn bar<T: Send>(_: T) {}
fn main() {
let x = Foo { a: 5 };
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned`
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Send`
}

View file

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f<T:Owned>(_i: T) {
fn f<T:Send>(_i: T) {
}
fn main() {
let i = ~@100;
f(i); //~ ERROR does not fulfill `Owned`
f(i); //~ ERROR does not fulfill `Send`
}

View file

@ -27,6 +27,6 @@ fn foo(i:int, j: @~str) -> foo {
fn main() {
let cat = ~"kitty";
let (_, ch) = comm::stream(); //~ ERROR does not fulfill `Owned`
ch.send(foo(42, @(cat))); //~ ERROR does not fulfill `Owned`
let (_, ch) = comm::stream(); //~ ERROR does not fulfill `Send`
ch.send(foo(42, @(cat))); //~ ERROR does not fulfill `Send`
}

View file

@ -19,6 +19,6 @@ struct chan_t<T> {
port: port_id,
}
fn send<T:Owned>(ch: chan_t<T>, data: T) { fail!(); }
fn send<T:Send>(ch: chan_t<T>, data: T) { fail!(); }
fn main() { fail!("quux"); }

View file

@ -23,7 +23,7 @@ fn make_cycle<A:Copy>(a: A) {
g.rec = Some(g);
}
fn f<A:Owned + Copy,B:Owned + Copy>(a: A, b: B) -> @fn() -> (A, B) {
fn f<A:Send + Copy,B:Send + Copy>(a: A, b: B) -> @fn() -> (A, B) {
let result: @fn() -> (A, B) = || (copy a, copy b);
result
}

View file

@ -10,11 +10,11 @@
// xfail-fast
fn fix_help<A:'static,B:Owned>(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B {
fn fix_help<A:'static,B:Send>(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B {
return f(|a| fix_help(f, a), x);
}
fn fix<A:'static,B:Owned>(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B {
fn fix<A:'static,B:Send>(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B {
return |a| fix_help(f, a);
}

View file

@ -10,7 +10,7 @@
// This is what the signature to spawn should look like with bare functions
fn spawn<T:Owned>(val: T, f: extern fn(T)) {
fn spawn<T:Send>(val: T, f: extern fn(T)) {
f(val);
}

View file

@ -10,7 +10,7 @@
fn id<T:Copy + Owned>(t: T) -> T { return t; }
fn id<T:Copy + Send>(t: T) -> T { return t; }
pub fn main() {
let expected = ~100;

View file

@ -39,7 +39,7 @@ pub mod pipes {
payload: Option<T>
}
pub fn packet<T:Owned>() -> *packet<T> {
pub fn packet<T:Send>() -> *packet<T> {
unsafe {
let p: *packet<T> = cast::transmute(~Stuff{
state: empty,
@ -74,7 +74,7 @@ pub mod pipes {
}
}
pub fn send<T:Owned>(mut p: send_packet<T>, payload: T) {
pub fn send<T:Send>(mut p: send_packet<T>, payload: T) {
let mut p = p.unwrap();
let mut p = unsafe { uniquify(p) };
assert!((*p).payload.is_none());
@ -100,7 +100,7 @@ pub mod pipes {
}
}
pub fn recv<T:Owned>(mut p: recv_packet<T>) -> Option<T> {
pub fn recv<T:Send>(mut p: recv_packet<T>) -> Option<T> {
let mut p = p.unwrap();
let mut p = unsafe { uniquify(p) };
loop {
@ -120,7 +120,7 @@ pub mod pipes {
}
}
pub fn sender_terminate<T:Owned>(mut p: *packet<T>) {
pub fn sender_terminate<T:Send>(mut p: *packet<T>) {
let mut p = unsafe { uniquify(p) };
match swap_state_rel(&mut (*p).state, terminated) {
empty | blocked => {
@ -137,7 +137,7 @@ pub mod pipes {
}
}
pub fn receiver_terminate<T:Owned>(mut p: *packet<T>) {
pub fn receiver_terminate<T:Send>(mut p: *packet<T>) {
let mut p = unsafe { uniquify(p) };
match swap_state_rel(&mut (*p).state, terminated) {
empty => {
@ -159,7 +159,7 @@ pub mod pipes {
}
#[unsafe_destructor]
impl<T:Owned> Drop for send_packet<T> {
impl<T:Send> Drop for send_packet<T> {
fn drop(&self) {
unsafe {
if self.p != None {
@ -172,13 +172,13 @@ pub mod pipes {
}
}
impl<T:Owned> send_packet<T> {
impl<T:Send> send_packet<T> {
pub fn unwrap(&mut self) -> *packet<T> {
util::replace(&mut self.p, None).unwrap()
}
}
pub fn send_packet<T:Owned>(p: *packet<T>) -> send_packet<T> {
pub fn send_packet<T:Send>(p: *packet<T>) -> send_packet<T> {
send_packet {
p: Some(p)
}
@ -189,7 +189,7 @@ pub mod pipes {
}
#[unsafe_destructor]
impl<T:Owned> Drop for recv_packet<T> {
impl<T:Send> Drop for recv_packet<T> {
fn drop(&self) {
unsafe {
if self.p != None {
@ -202,19 +202,19 @@ pub mod pipes {
}
}
impl<T:Owned> recv_packet<T> {
impl<T:Send> recv_packet<T> {
pub fn unwrap(&mut self) -> *packet<T> {
util::replace(&mut self.p, None).unwrap()
}
}
pub fn recv_packet<T:Owned>(p: *packet<T>) -> recv_packet<T> {
pub fn recv_packet<T:Send>(p: *packet<T>) -> recv_packet<T> {
recv_packet {
p: Some(p)
}
}
pub fn entangle<T:Owned>() -> (send_packet<T>, recv_packet<T>) {
pub fn entangle<T:Send>() -> (send_packet<T>, recv_packet<T>) {
let p = packet();
(send_packet(p), recv_packet(p))
}

View file

@ -12,7 +12,7 @@
//
proto! streamp (
open:send<T:Owned> {
open:send<T:Send> {
data(T) -> open<T>
}
)

View file

@ -9,7 +9,7 @@
// except according to those terms.
proto! stream (
Stream:send<T:Owned> {
Stream:send<T:Send> {
send(T) -> Stream<T>
}
)

View file

@ -45,7 +45,7 @@ proto! bank (
}
)
fn switch<T:Owned,U>(endp: pipes::RecvPacket<T>,
fn switch<T:Send,U>(endp: pipes::RecvPacket<T>,
f: &fn(v: Option<T>) -> U) -> U {
f(pipes::try_recv(endp))
}

View file

@ -29,12 +29,12 @@ proto! oneshot (
)
proto! stream (
Stream:send<T:Owned> {
Stream:send<T:Send> {
send(T) -> Stream<T>
}
)
pub fn spawn_service<T:Owned,Tb:Owned>(
pub fn spawn_service<T:Send,Tb:Send>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
service: ~fn(v: RecvPacketBuffered<T, Tb>))

View file

@ -33,7 +33,7 @@ endpoint. The send endpoint is returned to the caller and the receive
endpoint is passed to the new task.
*/
pub fn spawn_service<T:Owned,Tb:Owned>(
pub fn spawn_service<T:Send,Tb:Send>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
service: ~fn(v: RecvPacketBuffered<T, Tb>))

View file

@ -16,7 +16,7 @@ struct Command<K, V> {
val: V
}
fn cache_server<K:Owned,V:Owned>(c: Chan<Chan<Command<K, V>>>) {
fn cache_server<K:Send,V:Send>(c: Chan<Chan<Command<K, V>>>) {
let (ctrl_port, ctrl_chan) = stream();
c.send(ctrl_chan);
}

View file

@ -12,7 +12,7 @@
fn p_foo<T>(pinned: T) { }
fn s_foo<T:Copy>(shared: T) { }
fn u_foo<T:Owned>(unique: T) { }
fn u_foo<T:Send>(unique: T) { }
struct r {
i: int,

View file

@ -20,7 +20,7 @@ struct Pointy {
d : ~fn() -> uint,
}
fn make_uniq_closure<A:Owned + Copy>(a: A) -> ~fn() -> uint {
fn make_uniq_closure<A:Send + Copy>(a: A) -> ~fn() -> uint {
let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
result
}

View file

@ -12,11 +12,11 @@ use std::cmp::Eq;
fn sendable() {
fn f<T:Owned + Eq>(i: T, j: T) {
fn f<T:Send + Eq>(i: T, j: T) {
assert_eq!(i, j);
}
fn g<T:Owned + Eq>(i: T, j: T) {
fn g<T:Send + Eq>(i: T, j: T) {
assert!(i != j);
}