Rename Send trait to Owned

This commit is contained in:
Brian Anderson 2012-12-11 13:50:04 -08:00
parent a277081ee4
commit ed4fac01b5
49 changed files with 290 additions and 279 deletions

View File

@ -57,7 +57,7 @@ use libc::size_t;
* transmitted. If a port value is copied, both copies refer to the same
* port. Ports may be associated with multiple `chan`s.
*/
pub enum Port<T: Send> {
pub enum Port<T: Owned> {
Port_(@PortPtr<T>)
}
@ -73,16 +73,16 @@ pub enum Port<T: Send> {
* data will be silently dropped. Channels may be duplicated and
* themselves transmitted over other channels.
*/
pub enum Chan<T: Send> {
pub enum Chan<T: Owned> {
Chan_(port_id)
}
/// Constructs a port
pub fn Port<T: Send>() -> Port<T> {
pub fn Port<T: Owned>() -> Port<T> {
Port_(@PortPtr(rustrt::new_port(sys::size_of::<T>() as size_t)))
}
impl<T: Send> Port<T> {
impl<T: Owned> Port<T> {
fn chan() -> Chan<T> { Chan(&self) }
fn send(v: T) { self.chan().send(move v) }
@ -91,7 +91,7 @@ impl<T: Send> Port<T> {
}
impl<T: Send> Chan<T> {
impl<T: Owned> Chan<T> {
fn chan() -> Chan<T> { self }
fn send(v: T) { send(self, move v) }
@ -101,12 +101,12 @@ impl<T: Send> Chan<T> {
}
/// Open a new receiving channel for the duration of a function
pub fn listen<T: Send, U>(f: fn(Chan<T>) -> U) -> U {
pub fn listen<T: Owned, U>(f: fn(Chan<T>) -> U) -> U {
let po = Port();
f(po.chan())
}
struct PortPtr<T:Send> {
struct PortPtr<T:Owned> {
po: *rust_port,
drop unsafe {
do task::unkillable {
@ -130,7 +130,7 @@ struct PortPtr<T:Send> {
}
}
fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
fn PortPtr<T: Owned>(po: *rust_port) -> PortPtr<T> {
PortPtr {
po: po
}
@ -144,7 +144,7 @@ fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
* Fails if the port is detached or dead. Fails if the port
* is owned by a different task.
*/
fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
fn as_raw_port<T: Owned, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
struct PortRef {
p: *rust_port,
@ -176,7 +176,7 @@ fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
* Constructs a channel. The channel is bound to the port used to
* construct it.
*/
pub fn Chan<T: Send>(p: &Port<T>) -> Chan<T> {
pub fn Chan<T: Owned>(p: &Port<T>) -> Chan<T> {
Chan_(rustrt::get_port_id((**p).po))
}
@ -184,7 +184,7 @@ pub fn Chan<T: Send>(p: &Port<T>) -> Chan<T> {
* Sends data over a channel. The sent data is moved into the channel,
* whereupon the caller loses access to it.
*/
pub fn send<T: Send>(ch: Chan<T>, data: T) {
pub fn send<T: Owned>(ch: Chan<T>, data: T) {
let Chan_(p) = ch;
let data_ptr = ptr::addr_of(&data) as *();
let res = rustrt::rust_port_id_send(p, data_ptr);
@ -199,22 +199,22 @@ pub fn send<T: Send>(ch: Chan<T>, data: T) {
* Receive from a port. If no data is available on the port then the
* task will block until data becomes available.
*/
pub fn recv<T: Send>(p: Port<T>) -> T { recv_((**p).po) }
pub fn recv<T: Owned>(p: Port<T>) -> T { recv_((**p).po) }
/// Returns true if there are messages available
pub fn peek<T: Send>(p: Port<T>) -> bool { peek_((**p).po) }
pub fn peek<T: Owned>(p: Port<T>) -> bool { peek_((**p).po) }
#[doc(hidden)]
pub fn recv_chan<T: Send>(ch: comm::Chan<T>) -> T {
pub fn recv_chan<T: Owned>(ch: comm::Chan<T>) -> T {
as_raw_port(ch, |x|recv_(x))
}
fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
fn peek_chan<T: Owned>(ch: comm::Chan<T>) -> bool {
as_raw_port(ch, |x|peek_(x))
}
/// Receive on a raw port pointer
fn recv_<T: Send>(p: *rust_port) -> T {
fn recv_<T: Owned>(p: *rust_port) -> T {
let yield = 0;
let yieldp = ptr::addr_of(&yield);
let mut res;
@ -240,7 +240,7 @@ fn peek_(p: *rust_port) -> bool {
}
/// Receive on one of two ports
pub fn select2<A: Send, B: Send>(p_a: Port<A>, p_b: Port<B>)
pub fn select2<A: Owned, B: Owned>(p_a: Port<A>, p_b: Port<B>)
-> Either<A, B> {
let ports = ~[(**p_a).po, (**p_b).po];
let yield = 0, yieldp = ptr::addr_of(&yield);

View File

@ -167,7 +167,7 @@ pub mod util;
/* Reexported core operators */
pub use kinds::{Const, Copy, Send, Durable};
pub use kinds::{Const, Copy, Owned, Durable};
pub use ops::{Drop};
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
pub use ops::{BitAnd, BitOr, BitXor};

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`.
* Send - owned types and types containing owned types. These types
* Owned - owned types and types containing owned types. These types
may be transferred across task boundaries.
* Const - types that are deeply immutable. Const types are used for
@ -44,8 +44,17 @@ pub trait Copy {
// Empty.
}
#[cfg(stage0)]
#[lang="send"]
pub trait Send {
pub trait Owned {
// Empty.
}
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[lang="owned"]
pub trait Owned {
// Empty.
}

View File

@ -131,7 +131,7 @@ pub fn BufferHeader() -> BufferHeader{
// This is for protocols to associate extra data to thread around.
#[doc(hidden)]
type Buffer<T: Send> = {
type Buffer<T: Owned> = {
header: BufferHeader,
data: T,
};
@ -180,13 +180,13 @@ impl PacketHeader {
reinterpret_cast(&self.buffer)
}
fn set_buffer<T: Send>(b: ~Buffer<T>) unsafe {
fn set_buffer<T: Owned>(b: ~Buffer<T>) unsafe {
self.buffer = reinterpret_cast(&b);
}
}
#[doc(hidden)]
pub type Packet<T: Send> = {
pub type Packet<T: Owned> = {
header: PacketHeader,
mut payload: Option<T>,
};
@ -197,14 +197,14 @@ pub trait HasBuffer {
fn set_buffer_(b: *libc::c_void);
}
impl<T: Send> Packet<T>: HasBuffer {
impl<T: Owned> Packet<T>: HasBuffer {
fn set_buffer_(b: *libc::c_void) {
self.header.buffer = b;
}
}
#[doc(hidden)]
pub fn mk_packet<T: Send>() -> Packet<T> {
pub fn mk_packet<T: Owned>() -> Packet<T> {
{
header: PacketHeader(),
mut payload: None
@ -212,7 +212,7 @@ pub fn mk_packet<T: Send>() -> Packet<T> {
}
#[doc(hidden)]
fn unibuffer<T: Send>() -> ~Buffer<Packet<T>> {
fn unibuffer<T: Owned>() -> ~Buffer<Packet<T>> {
let b = ~{
header: BufferHeader(),
data: {
@ -228,7 +228,7 @@ fn unibuffer<T: Send>() -> ~Buffer<Packet<T>> {
}
#[doc(hidden)]
pub fn packet<T: Send>() -> *Packet<T> {
pub fn packet<T: Owned>() -> *Packet<T> {
let b = unibuffer();
let p = ptr::addr_of(&(b.data));
// We'll take over memory management from here.
@ -237,7 +237,7 @@ pub fn packet<T: Send>() -> *Packet<T> {
}
#[doc(hidden)]
pub fn entangle_buffer<T: Send, Tstart: Send>(
pub fn entangle_buffer<T: Owned, Tstart: Owned>(
buffer: ~Buffer<T>,
init: fn(*libc::c_void, x: &T) -> *Packet<Tstart>)
-> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>)
@ -329,12 +329,12 @@ fn swap_state_rel(dst: &mut State, src: State) -> State {
}
#[doc(hidden)]
pub unsafe fn get_buffer<T: Send>(p: *PacketHeader) -> ~Buffer<T> {
pub unsafe fn get_buffer<T: Owned>(p: *PacketHeader) -> ~Buffer<T> {
transmute((*p).buf_header())
}
// This could probably be done with SharedMutableState to avoid move_it!().
struct BufferResource<T: Send> {
struct BufferResource<T: Owned> {
buffer: ~Buffer<T>,
drop unsafe {
@ -354,7 +354,7 @@ struct BufferResource<T: Send> {
}
}
fn BufferResource<T: Send>(b: ~Buffer<T>) -> BufferResource<T> {
fn BufferResource<T: Owned>(b: ~Buffer<T>) -> BufferResource<T> {
//let p = ptr::addr_of(*b);
//error!("take %?", p);
atomic_add_acq(&mut b.header.ref_count, 1);
@ -366,7 +366,7 @@ fn BufferResource<T: Send>(b: ~Buffer<T>) -> BufferResource<T> {
}
#[doc(hidden)]
pub fn send<T: Send, Tbuffer: Send>(p: SendPacketBuffered<T, Tbuffer>,
pub fn send<T: Owned, Tbuffer: Owned>(p: SendPacketBuffered<T, Tbuffer>,
payload: T) -> bool {
let header = p.header();
let p_ = p.unwrap();
@ -410,7 +410,8 @@ pub fn send<T: Send, Tbuffer: Send>(p: SendPacketBuffered<T, Tbuffer>,
Fails if the sender closes the connection.
*/
pub fn recv<T: Send, Tbuffer: Send>(p: RecvPacketBuffered<T, Tbuffer>) -> T {
pub fn recv<T: Owned, Tbuffer: Owned>(
p: RecvPacketBuffered<T, Tbuffer>) -> T {
option::unwrap_expect(try_recv(move p), "connection closed")
}
@ -420,7 +421,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: Send, Tbuffer: Send>(p: RecvPacketBuffered<T, Tbuffer>)
pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>)
-> Option<T>
{
let p_ = p.unwrap();
@ -519,7 +520,7 @@ pub fn try_recv<T: Send, Tbuffer: Send>(p: RecvPacketBuffered<T, Tbuffer>)
}
/// Returns true if messages are available.
pub pure fn peek<T: Send, Tb: Send>(p: &RecvPacketBuffered<T, Tb>) -> bool {
pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool {
match unsafe {(*p.header()).state} {
Empty | Terminated => false,
Blocked => fail ~"peeking on blocked packet",
@ -527,14 +528,14 @@ pub pure fn peek<T: Send, Tb: Send>(p: &RecvPacketBuffered<T, Tb>) -> bool {
}
}
impl<T: Send, Tb: Send> RecvPacketBuffered<T, Tb>: Peekable<T> {
impl<T: Owned, Tb: Owned> RecvPacketBuffered<T, Tb>: Peekable<T> {
pure fn peek() -> bool {
peek(&self)
}
}
#[doc(hidden)]
fn sender_terminate<T: Send>(p: *Packet<T>) {
fn sender_terminate<T: Owned>(p: *Packet<T>) {
let p = unsafe { &*p };
match swap_state_rel(&mut p.header.state, Terminated) {
Empty => {
@ -563,7 +564,7 @@ fn sender_terminate<T: Send>(p: *Packet<T>) {
}
#[doc(hidden)]
fn receiver_terminate<T: Send>(p: *Packet<T>) {
fn receiver_terminate<T: Owned>(p: *Packet<T>) {
let p = unsafe { &*p };
match swap_state_rel(&mut p.header.state, Terminated) {
Empty => {
@ -671,7 +672,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: Send, Ab: Send, B: Send, Bb: Send>(
pub fn select2<A: Owned, Ab: Owned, B: Owned, Bb: Owned>(
a: RecvPacketBuffered<A, Ab>,
b: RecvPacketBuffered<B, Bb>)
-> Either<(Option<A>, RecvPacketBuffered<B, Bb>),
@ -714,7 +715,7 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) ->
list of the remaining endpoints.
*/
pub fn select<T: Send, Tb: Send>(endpoints: ~[RecvPacketBuffered<T, Tb>])
pub fn select<T: Owned, Tb: Owned>(endpoints: ~[RecvPacketBuffered<T, Tb>])
-> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>])
{
let ready = wait_many(endpoints.map(|p| p.header()));
@ -728,14 +729,14 @@ pub fn select<T: Send, Tb: Send>(endpoints: ~[RecvPacketBuffered<T, Tb>])
message.
*/
pub type SendPacket<T: Send> = SendPacketBuffered<T, Packet<T>>;
pub type SendPacket<T: Owned> = SendPacketBuffered<T, Packet<T>>;
#[doc(hidden)]
pub fn SendPacket<T: Send>(p: *Packet<T>) -> SendPacket<T> {
pub fn SendPacket<T: Owned>(p: *Packet<T>) -> SendPacket<T> {
SendPacketBuffered(p)
}
pub struct SendPacketBuffered<T: Send, Tbuffer: Send> {
pub struct SendPacketBuffered<T: Owned, Tbuffer: Owned> {
mut p: Option<*Packet<T>>,
mut buffer: Option<BufferResource<Tbuffer>>,
drop {
@ -754,7 +755,7 @@ pub struct SendPacketBuffered<T: Send, Tbuffer: Send> {
}
}
pub fn SendPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
pub fn SendPacketBuffered<T: Owned, Tbuffer: Owned>(p: *Packet<T>)
-> SendPacketBuffered<T, Tbuffer> {
//debug!("take send %?", p);
SendPacketBuffered {
@ -766,7 +767,7 @@ pub fn SendPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
}
}
impl<T: Send, Tbuffer: Send> SendPacketBuffered<T, Tbuffer> {
impl<T: Owned, Tbuffer: Owned> SendPacketBuffered<T, Tbuffer> {
fn unwrap() -> *Packet<T> {
let mut p = None;
p <-> self.p;
@ -795,14 +796,14 @@ impl<T: Send, Tbuffer: Send> SendPacketBuffered<T, Tbuffer> {
/// Represents the receive end of a pipe. It can receive exactly one
/// message.
pub type RecvPacket<T: Send> = RecvPacketBuffered<T, Packet<T>>;
pub type RecvPacket<T: Owned> = RecvPacketBuffered<T, Packet<T>>;
#[doc(hidden)]
pub fn RecvPacket<T: Send>(p: *Packet<T>) -> RecvPacket<T> {
pub fn RecvPacket<T: Owned>(p: *Packet<T>) -> RecvPacket<T> {
RecvPacketBuffered(p)
}
pub struct RecvPacketBuffered<T: Send, Tbuffer: Send> {
pub struct RecvPacketBuffered<T: Owned, Tbuffer: Owned> {
mut p: Option<*Packet<T>>,
mut buffer: Option<BufferResource<Tbuffer>>,
drop {
@ -821,7 +822,7 @@ pub struct RecvPacketBuffered<T: Send, Tbuffer: Send> {
}
}
impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> {
impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> {
fn unwrap() -> *Packet<T> {
let mut p = None;
p <-> self.p;
@ -836,7 +837,7 @@ impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> {
}
}
impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> : Selectable {
impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> : Selectable {
pure fn header() -> *PacketHeader {
match self.p {
Some(packet) => unsafe {
@ -850,7 +851,7 @@ impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> : Selectable {
}
}
pub fn RecvPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
pub fn RecvPacketBuffered<T: Owned, Tbuffer: Owned>(p: *Packet<T>)
-> RecvPacketBuffered<T, Tbuffer> {
//debug!("take recv %?", p);
RecvPacketBuffered {
@ -863,7 +864,7 @@ pub fn RecvPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
}
#[doc(hidden)]
pub fn entangle<T: Send>() -> (SendPacket<T>, RecvPacket<T>) {
pub fn entangle<T: Owned>() -> (SendPacket<T>, RecvPacket<T>) {
let p = packet();
(SendPacket(p), RecvPacket(p))
}
@ -875,7 +876,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: Send, Tb: Send>(
pub fn spawn_service<T: Owned, Tb: Owned>(
init: extern fn() -> (SendPacketBuffered<T, Tb>,
RecvPacketBuffered<T, Tb>),
service: fn~(v: RecvPacketBuffered<T, Tb>))
@ -899,7 +900,7 @@ pub fn spawn_service<T: Send, Tb: Send>(
receive state.
*/
pub fn spawn_service_recv<T: Send, Tb: Send>(
pub fn spawn_service_recv<T: Owned, Tb: Owned>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
service: fn~(v: SendPacketBuffered<T, Tb>))
@ -922,7 +923,7 @@ pub fn spawn_service_recv<T: Send, Tb: Send>(
// Streams - Make pipes a little easier in general.
proto! streamp (
Open:send<T: Send> {
Open:send<T: Owned> {
data(T) -> Open<T>
}
)
@ -958,18 +959,18 @@ pub trait Peekable<T> {
}
#[doc(hidden)]
type Chan_<T:Send> = { mut endp: Option<streamp::client::Open<T>> };
type Chan_<T:Owned> = { mut endp: Option<streamp::client::Open<T>> };
/// An endpoint that can send many messages.
pub enum Chan<T:Send> {
pub enum Chan<T:Owned> {
Chan_(Chan_<T>)
}
#[doc(hidden)]
type Port_<T:Send> = { mut endp: Option<streamp::server::Open<T>> };
type Port_<T:Owned> = { mut endp: Option<streamp::server::Open<T>> };
/// An endpoint that can receive many messages.
pub enum Port<T:Send> {
pub enum Port<T:Owned> {
Port_(Port_<T>)
}
@ -978,13 +979,13 @@ pub enum Port<T:Send> {
These allow sending or receiving an unlimited number of messages.
*/
pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
let (c, s) = streamp::init();
(Port_({ mut endp: Some(move s) }), Chan_({ mut endp: Some(move c) }))
}
impl<T: Send> Chan<T>: GenericChan<T> {
impl<T: Owned> Chan<T>: GenericChan<T> {
fn send(x: T) {
let mut endp = None;
endp <-> self.endp;
@ -993,7 +994,7 @@ impl<T: Send> Chan<T>: GenericChan<T> {
}
}
impl<T: Send> Chan<T>: GenericSmartChan<T> {
impl<T: Owned> Chan<T>: GenericSmartChan<T> {
fn try_send(x: T) -> bool {
let mut endp = None;
@ -1008,7 +1009,7 @@ impl<T: Send> Chan<T>: GenericSmartChan<T> {
}
}
impl<T: Send> Port<T>: GenericPort<T> {
impl<T: Owned> Port<T>: GenericPort<T> {
fn recv() -> T {
let mut endp = None;
endp <-> self.endp;
@ -1030,7 +1031,7 @@ impl<T: Send> Port<T>: GenericPort<T> {
}
}
impl<T: Send> Port<T>: Peekable<T> {
impl<T: Owned> Port<T>: Peekable<T> {
pure fn peek() -> bool unsafe {
let mut endp = None;
endp <-> self.endp;
@ -1043,7 +1044,7 @@ impl<T: Send> Port<T>: Peekable<T> {
}
}
impl<T: Send> Port<T>: Selectable {
impl<T: Owned> Port<T>: Selectable {
pure fn header() -> *PacketHeader unsafe {
match self.endp {
Some(ref endp) => endp.header(),
@ -1053,17 +1054,17 @@ impl<T: Send> Port<T>: Selectable {
}
/// Treat many ports as one.
pub struct PortSet<T: Send> {
pub struct PortSet<T: Owned> {
mut ports: ~[pipes::Port<T>],
}
pub fn PortSet<T: Send>() -> PortSet<T>{
pub fn PortSet<T: Owned>() -> PortSet<T>{
PortSet {
ports: ~[]
}
}
impl<T: Send> PortSet<T> {
impl<T: Owned> PortSet<T> {
fn add(port: pipes::Port<T>) {
self.ports.push(move port)
@ -1076,7 +1077,7 @@ impl<T: Send> PortSet<T> {
}
}
impl<T: Send> PortSet<T> : GenericPort<T> {
impl<T: Owned> PortSet<T> : GenericPort<T> {
fn try_recv() -> Option<T> {
let mut result = None;
@ -1106,7 +1107,7 @@ impl<T: Send> PortSet<T> : GenericPort<T> {
}
impl<T: Send> PortSet<T> : Peekable<T> {
impl<T: Owned> PortSet<T> : Peekable<T> {
pure fn peek() -> bool {
// It'd be nice to use self.port.each, but that version isn't
// pure.
@ -1118,9 +1119,9 @@ impl<T: Send> PortSet<T> : Peekable<T> {
}
/// A channel that can be shared between many senders.
pub type SharedChan<T: Send> = private::Exclusive<Chan<T>>;
pub type SharedChan<T: Owned> = private::Exclusive<Chan<T>>;
impl<T: Send> SharedChan<T>: GenericChan<T> {
impl<T: Owned> SharedChan<T>: GenericChan<T> {
fn send(x: T) {
let mut xx = Some(move x);
do self.with_imm |chan| {
@ -1131,7 +1132,7 @@ impl<T: Send> SharedChan<T>: GenericChan<T> {
}
}
impl<T: Send> SharedChan<T>: GenericSmartChan<T> {
impl<T: Owned> SharedChan<T>: GenericSmartChan<T> {
fn try_send(x: T) -> bool {
let mut xx = Some(move x);
do self.with_imm |chan| {
@ -1143,19 +1144,19 @@ impl<T: Send> SharedChan<T>: GenericSmartChan<T> {
}
/// Converts a `chan` into a `shared_chan`.
pub fn SharedChan<T:Send>(c: Chan<T>) -> SharedChan<T> {
pub fn SharedChan<T:Owned>(c: Chan<T>) -> SharedChan<T> {
private::exclusive(move c)
}
/// Receive a message from one of two endpoints.
pub trait Select2<T: Send, U: Send> {
pub trait Select2<T: Owned, U: Owned> {
/// Receive a message or return `None` if a connection closes.
fn try_select() -> Either<Option<T>, Option<U>>;
/// Receive a message or fail if a connection closes.
fn select() -> Either<T, U>;
}
impl<T: Send, U: Send,
impl<T: Owned, U: Owned,
Left: Selectable GenericPort<T>,
Right: Selectable GenericPort<U>>
(Left, Right): Select2<T, U> {
@ -1180,18 +1181,18 @@ impl<T: Send, U: Send,
}
proto! oneshot (
Oneshot:send<T:Send> {
Oneshot:send<T:Owned> {
send(T) -> !
}
)
/// The send end of a oneshot pipe.
pub type ChanOne<T: Send> = oneshot::client::Oneshot<T>;
pub type ChanOne<T: Owned> = oneshot::client::Oneshot<T>;
/// The receive end of a oneshot pipe.
pub type PortOne<T: Send> = oneshot::server::Oneshot<T>;
pub type PortOne<T: Owned> = oneshot::server::Oneshot<T>;
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
pub fn oneshot<T: Send>() -> (ChanOne<T>, PortOne<T>) {
pub fn oneshot<T: Owned>() -> (ChanOne<T>, PortOne<T>) {
oneshot::init()
}
@ -1199,13 +1200,13 @@ pub fn oneshot<T: Send>() -> (ChanOne<T>, PortOne<T>) {
* Receive a message from a oneshot pipe, failing if the connection was
* closed.
*/
pub fn recv_one<T: Send>(port: PortOne<T>) -> T {
pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
let oneshot::send(message) = recv(move port);
move message
}
/// Receive a message from a oneshot pipe unless the connection was closed.
pub fn try_recv_one<T: Send> (port: PortOne<T>) -> Option<T> {
pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {
let message = try_recv(move port);
if message.is_none() { None }
@ -1216,7 +1217,7 @@ pub fn try_recv_one<T: Send> (port: PortOne<T>) -> Option<T> {
}
/// Send a message on a oneshot pipe, failing if the connection was closed.
pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) {
pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
oneshot::client::send(move chan, move data);
}
@ -1224,7 +1225,7 @@ pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) {
* Send a message on a oneshot pipe, or return false if the connection was
* closed.
*/
pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T)
pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T)
-> bool {
oneshot::client::try_send(move chan, move data).is_some()
}

View File

@ -52,7 +52,7 @@ fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool {
* or, if no channel exists creates and installs a new channel and sets up a
* new task to receive from it.
*/
pub unsafe fn chan_from_global_ptr<T: Send>(
pub unsafe fn chan_from_global_ptr<T: Owned>(
global: GlobalPtr,
task_fn: fn() -> task::TaskBuilder,
f: fn~(comm::Port<T>)
@ -350,7 +350,7 @@ fn ArcDestruct<T>(data: *libc::c_void) -> ArcDestruct<T> {
}
}
pub unsafe fn unwrap_shared_mutable_state<T: Send>(rc: SharedMutableState<T>)
pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>)
-> T {
struct DeathThroes<T> {
mut ptr: Option<~ArcData<T>>,
@ -421,9 +421,9 @@ pub unsafe fn unwrap_shared_mutable_state<T: Send>(rc: SharedMutableState<T>)
* Data races between tasks can result in crashes and, with sufficient
* cleverness, arbitrary type coercion.
*/
pub type SharedMutableState<T: Send> = ArcDestruct<T>;
pub type SharedMutableState<T: Owned> = ArcDestruct<T>;
pub unsafe fn shared_mutable_state<T: Send>(data: T) ->
pub unsafe fn shared_mutable_state<T: Owned>(data: T) ->
SharedMutableState<T> {
let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) };
unsafe {
@ -433,7 +433,7 @@ pub unsafe fn shared_mutable_state<T: Send>(data: T) ->
}
#[inline(always)]
pub unsafe fn get_shared_mutable_state<T: Send>(rc: &a/SharedMutableState<T>)
pub unsafe fn get_shared_mutable_state<T: Owned>(rc: &a/SharedMutableState<T>)
-> &a/mut T {
unsafe {
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
@ -445,7 +445,7 @@ pub unsafe fn get_shared_mutable_state<T: Send>(rc: &a/SharedMutableState<T>)
}
}
#[inline(always)]
pub unsafe fn get_shared_immutable_state<T: Send>(
pub unsafe fn get_shared_immutable_state<T: Owned>(
rc: &a/SharedMutableState<T>) -> &a/T {
unsafe {
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
@ -457,7 +457,7 @@ pub unsafe fn get_shared_immutable_state<T: Send>(
}
}
pub unsafe fn clone_shared_mutable_state<T: Send>(rc: &SharedMutableState<T>)
pub unsafe fn clone_shared_mutable_state<T: Owned>(rc: &SharedMutableState<T>)
-> SharedMutableState<T> {
unsafe {
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
@ -506,27 +506,27 @@ impl LittleLock {
}
}
struct ExData<T: Send> { lock: LittleLock, mut failed: bool, mut data: T, }
struct ExData<T: Owned> { lock: LittleLock, mut failed: bool, mut data: T, }
/**
* An arc over mutable data that is protected by a lock. For library use only.
*/
pub struct Exclusive<T: Send> { x: SharedMutableState<ExData<T>> }
pub struct Exclusive<T: Owned> { x: SharedMutableState<ExData<T>> }
pub fn exclusive<T:Send >(user_data: T) -> Exclusive<T> {
pub fn exclusive<T:Owned >(user_data: T) -> Exclusive<T> {
let data = ExData {
lock: LittleLock(), mut failed: false, mut data: move user_data
};
Exclusive { x: unsafe { shared_mutable_state(move data) } }
}
impl<T: Send> Exclusive<T>: Clone {
impl<T: Owned> Exclusive<T>: Clone {
// Duplicate an exclusive ARC, as std::arc::clone.
fn clone(&self) -> Exclusive<T> {
Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } }
}
}
impl<T: Send> Exclusive<T> {
impl<T: Owned> Exclusive<T> {
// Exactly like std::arc::mutex_arc,access(), but with the little_lock
// instead of a proper mutex. Same reason for being unsafe.
//
@ -556,7 +556,7 @@ impl<T: Send> Exclusive<T> {
}
// FIXME(#3724) make this a by-move method on the exclusive
pub fn unwrap_exclusive<T: Send>(arc: Exclusive<T>) -> T {
pub fn unwrap_exclusive<T: Owned>(arc: Exclusive<T>) -> T {
let Exclusive { x: x } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let ExData { data: data, _ } = move inner;

View File

@ -425,7 +425,7 @@ impl TaskBuilder {
spawn::spawn_raw(move opts, (x.gen_body)(move f));
}
/// Runs a task, while transfering ownership of one argument to the child.
fn spawn_with<A: Send>(arg: A, f: fn~(v: A)) {
fn spawn_with<A: Owned>(arg: A, f: fn~(v: A)) {
let arg = ~mut Some(move arg);
do self.spawn |move arg, move f| {
f(option::swap_unwrap(arg))
@ -443,7 +443,7 @@ impl TaskBuilder {
* otherwise be required to establish communication from the parent
* to the child.
*/
fn spawn_listener<A: Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
fn spawn_listener<A: Owned>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
let setup_po = comm::Port();
let setup_ch = comm::Chan(&setup_po);
do self.spawn |move f| {
@ -458,7 +458,7 @@ impl TaskBuilder {
/**
* Runs a new task, setting up communication in both directions
*/
fn spawn_conversation<A: Send, B: Send>
fn spawn_conversation<A: Owned, B: Owned>
(f: fn~(comm::Port<A>, comm::Chan<B>))
-> (comm::Port<B>, comm::Chan<A>) {
let from_child = comm::Port();
@ -482,7 +482,7 @@ impl TaskBuilder {
* # Failure
* Fails if a future_result was already set for this task.
*/
fn try<T: Send>(f: fn~() -> T) -> Result<T,()> {
fn try<T: Owned>(f: fn~() -> T) -> Result<T,()> {
let po = comm::Port();
let ch = comm::Chan(&po);
let mut result = None;
@ -552,7 +552,7 @@ pub fn spawn_supervised(f: fn~()) {
task().supervised().spawn(move f)
}
pub fn spawn_with<A:Send>(arg: A, f: fn~(v: A)) {
pub fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) {
/*!
* Runs a task, while transfering ownership of one argument to the
* child.
@ -566,7 +566,7 @@ pub fn spawn_with<A:Send>(arg: A, f: fn~(v: A)) {
task().spawn_with(move arg, move f)
}
pub fn spawn_listener<A:Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
pub fn spawn_listener<A:Owned>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
/*!
* Runs a new task while providing a channel from the parent to the child
*
@ -576,7 +576,7 @@ pub fn spawn_listener<A:Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
task().spawn_listener(move f)
}
pub fn spawn_conversation<A: Send, B: Send>
pub fn spawn_conversation<A: Owned, B: Owned>
(f: fn~(comm::Port<A>, comm::Chan<B>))
-> (comm::Port<B>, comm::Chan<A>) {
/*!
@ -605,7 +605,7 @@ pub fn spawn_sched(mode: SchedMode, f: fn~()) {
task().sched_mode(mode).spawn(move f)
}
pub fn try<T:Send>(f: fn~() -> T) -> Result<T,()> {
pub fn try<T:Owned>(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

@ -484,7 +484,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] {
let mut bounds = ~[];
loop {
bounds.push(match next(st) {
'S' => ty::bound_send,
'S' => ty::bound_owned,
'C' => ty::bound_copy,
'K' => ty::bound_const,
'O' => ty::bound_durable,

View File

@ -392,7 +392,7 @@ fn enc_ty_fn(w: io::Writer, cx: @ctxt, ft: ty::FnTy) {
fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
for vec::each(*bs) |bound| {
match *bound {
ty::bound_send => w.write_char('S'),
ty::bound_owned => w.write_char('S'),
ty::bound_copy => w.write_char('C'),
ty::bound_const => w.write_char('K'),
ty::bound_durable => w.write_char('O'),

View File

@ -63,7 +63,7 @@ fn kind_to_str(k: Kind) -> ~str {
}
if ty::kind_can_be_sent(k) {
kinds.push(~"send");
kinds.push(~"owned");
} else if ty::kind_is_durable(k) {
kinds.push(~"durable");
}

View File

@ -13,7 +13,7 @@
// Language items are items that represent concepts intrinsic to the language
// itself. Examples are:
//
// * Traits that specify "kinds"; e.g. "const", "copy", "send".
// * Traits that specify "kinds"; e.g. "const", "copy", "owned".
//
// * Traits that represent operators; e.g. "add", "sub", "index".
//
@ -35,7 +35,7 @@ use str_eq = str::eq;
struct LanguageItems {
mut const_trait: Option<def_id>,
mut copy_trait: Option<def_id>,
mut send_trait: Option<def_id>,
mut owned_trait: Option<def_id>,
mut durable_trait: Option<def_id>,
mut drop_trait: Option<def_id>,
@ -68,7 +68,7 @@ mod language_items {
LanguageItems {
const_trait: None,
copy_trait: None,
send_trait: None,
owned_trait: None,
durable_trait: None,
drop_trait: None,
@ -105,7 +105,7 @@ fn LanguageItemCollector(crate: @crate, session: Session,
item_refs.insert(~"const", &mut items.const_trait);
item_refs.insert(~"copy", &mut items.copy_trait);
item_refs.insert(~"send", &mut items.send_trait);
item_refs.insert(~"owned", &mut items.owned_trait);
item_refs.insert(~"durable", &mut items.durable_trait);
item_refs.insert(~"drop", &mut items.drop_trait);

View File

@ -178,7 +178,7 @@ export occurs_check;
export param_ty;
export param_bound, param_bounds, bound_copy, bound_durable;
export param_bounds_to_str, param_bound_to_str;
export bound_send, bound_trait;
export bound_owned, bound_trait;
export param_bounds_to_kind;
export default_arg_mode_for_ty;
export item_path;
@ -703,7 +703,7 @@ enum type_err {
enum param_bound {
bound_copy,
bound_durable,
bound_send,
bound_owned,
bound_const,
bound_trait(t),
}
@ -770,7 +770,7 @@ impl param_bound : to_bytes::IterBytes {
match *self {
bound_copy => 0u8.iter_bytes(lsb0, f),
bound_durable => 1u8.iter_bytes(lsb0, f),
bound_send => 2u8.iter_bytes(lsb0, f),
bound_owned => 2u8.iter_bytes(lsb0, f),
bound_const => 3u8.iter_bytes(lsb0, f),
bound_trait(ref t) =>
to_bytes::iter_bytes_2(&4u8, t, lsb0, f)
@ -876,8 +876,8 @@ fn param_bounds_to_kind(bounds: param_bounds) -> Kind {
bound_durable => {
kind = raise_kind(kind, kind_durable());
}
bound_send => {
kind = raise_kind(kind, kind_send_only() | kind_durable());
bound_owned => {
kind = raise_kind(kind, kind_owned_only() | kind_durable());
}
bound_const => {
kind = raise_kind(kind, kind_const());
@ -1550,7 +1550,7 @@ fn param_bound_to_str(cx: ctxt, pb: &param_bound) -> ~str {
match *pb {
bound_copy => ~"copy",
bound_durable => ~"durable",
bound_send => ~"send",
bound_owned => ~"owned",
bound_const => ~"const",
bound_trait(t) => ty_to_str(cx, t)
}
@ -1908,8 +1908,8 @@ enum Kind { kind_(u32) }
/// can be copied (implicitly or explicitly)
const KIND_MASK_COPY : u32 = 0b000000000000000000000000001_u32;
/// can be sent: no shared box, borrowed ptr (must imply DURABLE)
const KIND_MASK_SEND : u32 = 0b000000000000000000000000010_u32;
/// no shared box, borrowed ptr (must imply DURABLE)
const KIND_MASK_OWNED : u32 = 0b000000000000000000000000010_u32;
/// is durable (no borrowed ptrs)
const KIND_MASK_DURABLE : u32 = 0b000000000000000000000000100_u32;
@ -1941,22 +1941,22 @@ fn kind_safe_for_default_mode() -> Kind {
}
fn kind_implicitly_sendable() -> Kind {
kind_(KIND_MASK_IMPLICIT | KIND_MASK_COPY | KIND_MASK_SEND)
kind_(KIND_MASK_IMPLICIT | KIND_MASK_COPY | KIND_MASK_OWNED)
}
fn kind_safe_for_default_mode_send() -> Kind {
// similar to implicit copy, but always includes vectors and strings
kind_(KIND_MASK_DEFAULT_MODE | KIND_MASK_IMPLICIT |
KIND_MASK_COPY | KIND_MASK_SEND)
KIND_MASK_COPY | KIND_MASK_OWNED)
}
fn kind_send_copy() -> Kind {
kind_(KIND_MASK_COPY | KIND_MASK_SEND)
fn kind_owned_copy() -> Kind {
kind_(KIND_MASK_COPY | KIND_MASK_OWNED)
}
fn kind_send_only() -> Kind {
kind_(KIND_MASK_SEND)
fn kind_owned_only() -> Kind {
kind_(KIND_MASK_OWNED)
}
fn kind_const() -> Kind {
@ -1979,12 +1979,12 @@ fn remove_implicit(k: Kind) -> Kind {
k - kind_(KIND_MASK_IMPLICIT | KIND_MASK_DEFAULT_MODE)
}
fn remove_send(k: Kind) -> Kind {
k - kind_(KIND_MASK_SEND)
fn remove_owned(k: Kind) -> Kind {
k - kind_(KIND_MASK_OWNED)
}
fn remove_durable_send(k: Kind) -> Kind {
k - kind_(KIND_MASK_DURABLE) - kind_(KIND_MASK_SEND)
fn remove_durable_owned(k: Kind) -> Kind {
k - kind_(KIND_MASK_DURABLE) - kind_(KIND_MASK_OWNED)
}
fn remove_copyable(k: Kind) -> Kind {
@ -2031,7 +2031,7 @@ pure fn kind_can_be_copied(k: Kind) -> bool {
}
pure fn kind_can_be_sent(k: Kind) -> bool {
*k & KIND_MASK_SEND == KIND_MASK_SEND
*k & KIND_MASK_OWNED == KIND_MASK_OWNED
}
pure fn kind_is_durable(k: Kind) -> bool {
@ -2050,7 +2050,7 @@ fn meta_kind(p: FnMeta) -> Kind {
kind_safe_for_default_mode() | kind_durable()
}
ast::ProtoUniq => {
kind_send_copy() | kind_durable()
kind_owned_copy() | kind_durable()
}
}
}
@ -2071,17 +2071,17 @@ fn raise_kind(a: Kind, b: Kind) -> Kind {
fn test_kinds() {
// The kind "lattice" is defined by the subset operation on the
// set of permitted operations.
assert kind_lteq(kind_send_copy(), kind_send_copy());
assert kind_lteq(kind_copyable(), kind_send_copy());
assert kind_lteq(kind_owned_copy(), kind_owned_copy());
assert kind_lteq(kind_copyable(), kind_owned_copy());
assert kind_lteq(kind_copyable(), kind_copyable());
assert kind_lteq(kind_noncopyable(), kind_send_copy());
assert kind_lteq(kind_noncopyable(), kind_owned_copy());
assert kind_lteq(kind_noncopyable(), kind_copyable());
assert kind_lteq(kind_noncopyable(), kind_noncopyable());
assert kind_lteq(kind_copyable(), kind_implicitly_copyable());
assert kind_lteq(kind_copyable(), kind_implicitly_sendable());
assert kind_lteq(kind_send_copy(), kind_implicitly_sendable());
assert !kind_lteq(kind_send_copy(), kind_implicitly_copyable());
assert !kind_lteq(kind_copyable(), kind_send_only());
assert kind_lteq(kind_owned_copy(), kind_implicitly_sendable());
assert !kind_lteq(kind_owned_copy(), kind_implicitly_copyable());
assert !kind_lteq(kind_copyable(), kind_owned_only());
}
// Return the most permissive kind that a composite object containing a field
@ -2121,7 +2121,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
if cx.vecs_implicitly_copyable {
kind_implicitly_sendable() | kind_const() | kind_durable()
} else {
kind_send_copy() | kind_const() | kind_durable()
kind_owned_copy() | kind_const() | kind_durable()
}
}
@ -2131,7 +2131,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
// Those with refcounts raise noncopyable to copyable,
// lower sendable to copyable. Therefore just set result to copyable.
ty_box(tm) => {
remove_send(mutable_type_kind(cx, tm) | kind_safe_for_default_mode())
remove_owned(mutable_type_kind(cx, tm) | kind_safe_for_default_mode())
}
// Trait instances are (for now) like shared boxes, basically
@ -2161,13 +2161,13 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
// contained type, but aren't implicitly copyable. Fixed vectors have
// the kind of the element they contain, taking mutability into account.
ty_evec(tm, vstore_box) => {
remove_send(kind_safe_for_default_mode() | mutable_type_kind(cx, tm))
remove_owned(kind_safe_for_default_mode() | mutable_type_kind(cx, tm))
}
ty_evec(tm, vstore_slice(re_static)) => {
kind_safe_for_default_mode() | mutable_type_kind(cx, tm)
}
ty_evec(tm, vstore_slice(_)) => {
remove_durable_send(kind_safe_for_default_mode() |
remove_durable_owned(kind_safe_for_default_mode() |
mutable_type_kind(cx, tm))
}
ty_evec(tm, vstore_fixed(_)) => {
@ -2179,7 +2179,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
kind_safe_for_default_mode() | kind_const() | kind_durable()
}
ty_estr(vstore_slice(re_static)) => {
kind_safe_for_default_mode() | kind_send_copy() | kind_const()
kind_safe_for_default_mode() | kind_owned_copy() | kind_const()
}
ty_estr(vstore_slice(_)) => {
kind_safe_for_default_mode() | kind_const()
@ -2226,7 +2226,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
let mut lowest = kind_top();
let variants = enum_variants(cx, did);
if vec::len(*variants) == 0u {
lowest = kind_send_only() | kind_durable();
lowest = kind_owned_only() | kind_durable();
} else {
for vec::each(*variants) |variant| {
for variant.args.each |aty| {
@ -4236,7 +4236,7 @@ fn iter_bound_traits_and_supertraits(tcx: ctxt,
let bound_trait_ty = match *bound {
ty::bound_trait(bound_t) => bound_t,
ty::bound_copy | ty::bound_send |
ty::bound_copy | ty::bound_owned |
ty::bound_const | ty::bound_durable => {
loop; // skip non-trait bounds
}
@ -4653,9 +4653,9 @@ impl param_bound : cmp::Eq {
_ => false
}
}
bound_send => {
bound_owned => {
match (*other) {
bound_send => true,
bound_owned => true,
_ => false
}
}

View File

@ -342,7 +342,7 @@ impl LookupContext {
let bound_trait_ty = match *bound {
ty::bound_trait(bound_t) => bound_t,
ty::bound_copy | ty::bound_send |
ty::bound_copy | ty::bound_owned |
ty::bound_const | ty::bound_durable => {
loop; // skip non-trait bounds
}

View File

@ -872,8 +872,8 @@ fn compute_bounds(ccx: @crate_ctxt,
match ty::get(ity).sty {
ty::ty_trait(did, _, _) => {
let d = Some(did);
if d == li.send_trait {
~[ty::bound_send]
if d == li.owned_trait {
~[ty::bound_owned]
}
else if d == li.copy_trait {
~[ty::bound_copy]

View File

@ -11,7 +11,7 @@
use std::map::HashMap;
use middle::ty;
use middle::ty::{arg, canon_mode};
use middle::ty::{bound_copy, bound_const, bound_durable, bound_send,
use middle::ty::{bound_copy, bound_const, bound_durable, bound_owned,
bound_trait};
use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid};
use middle::ty::{ctxt, field, method};

View File

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

View File

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

View File

@ -92,7 +92,7 @@ fn mk_fold<T:Clone>(
}
}
pub fn default_any_fold<T:Send Clone>(+ctxt: T) -> Fold<T> {
pub fn default_any_fold<T:Owned Clone>(+ctxt: T) -> Fold<T> {
mk_fold(
move ctxt,
|f, d| default_seq_fold_doc(f, d),
@ -128,7 +128,7 @@ pub fn default_seq_fold<T:Clone>(+ctxt: T) -> Fold<T> {
)
}
pub fn default_par_fold<T:Send Clone>(+ctxt: T) -> Fold<T> {
pub fn default_par_fold<T:Owned Clone>(+ctxt: T) -> Fold<T> {
mk_fold(
move ctxt,
|f, d| default_seq_fold_doc(f, d),
@ -178,7 +178,7 @@ pub fn default_seq_fold_item<T>(
doc
}
pub fn default_any_fold_mod<T:Send Clone>(
pub fn default_any_fold_mod<T:Owned Clone>(
fold: &Fold<T>,
+doc: doc::ModDoc
) -> doc::ModDoc {
@ -205,7 +205,7 @@ pub fn default_seq_fold_mod<T>(
})
}
pub fn default_par_fold_mod<T:Send Clone>(
pub fn default_par_fold_mod<T:Owned Clone>(
fold: &Fold<T>,
+doc: doc::ModDoc
) -> doc::ModDoc {
@ -219,7 +219,7 @@ pub fn default_par_fold_mod<T:Send Clone>(
})
}
pub fn default_any_fold_nmod<T:Send Clone>(
pub fn default_any_fold_nmod<T:Owned Clone>(
fold: &Fold<T>,
+doc: doc::NmodDoc
) -> doc::NmodDoc {
@ -246,7 +246,7 @@ pub fn default_seq_fold_nmod<T>(
}
}
pub fn default_par_fold_nmod<T:Send Clone>(
pub fn default_par_fold_nmod<T:Owned Clone>(
fold: &Fold<T>,
+doc: doc::NmodDoc
) -> doc::NmodDoc {

View File

@ -73,10 +73,10 @@ impl &Condvar {
****************************************************************************/
/// An atomically reference counted wrapper for shared immutable state.
struct ARC<T: Const Send> { x: SharedMutableState<T> }
struct ARC<T: Const Owned> { x: SharedMutableState<T> }
/// Create an atomically reference counted wrapper.
pub fn ARC<T: Const Send>(data: T) -> ARC<T> {
pub fn ARC<T: Const Owned>(data: T) -> ARC<T> {
ARC { x: unsafe { shared_mutable_state(move data) } }
}
@ -84,7 +84,7 @@ pub fn ARC<T: Const Send>(data: T) -> ARC<T> {
* Access the underlying data in an atomically reference counted
* wrapper.
*/
pub fn get<T: Const Send>(rc: &a/ARC<T>) -> &a/T {
pub fn get<T: Const Owned>(rc: &a/ARC<T>) -> &a/T {
unsafe { get_shared_immutable_state(&rc.x) }
}
@ -95,7 +95,7 @@ pub fn get<T: Const Send>(rc: &a/ARC<T>) -> &a/T {
* object. However, one of the `arc` objects can be sent to another task,
* allowing them to share the underlying data.
*/
pub fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> {
pub fn clone<T: Const Owned>(rc: &ARC<T>) -> ARC<T> {
ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } }
}
@ -108,12 +108,12 @@ pub fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> {
* unwrap from a task that holds another reference to the same ARC; it is
* guaranteed to deadlock.
*/
fn unwrap<T: Const Send>(rc: ARC<T>) -> T {
fn unwrap<T: Const Owned>(rc: ARC<T>) -> T {
let ARC { x: x } = move rc;
unsafe { unwrap_shared_mutable_state(move x) }
}
impl<T: Const Send> ARC<T>: Clone {
impl<T: Const Owned> ARC<T>: Clone {
fn clone(&self) -> ARC<T> {
clone(self)
}
@ -124,19 +124,19 @@ impl<T: Const Send> ARC<T>: Clone {
****************************************************************************/
#[doc(hidden)]
struct MutexARCInner<T: Send> { lock: Mutex, failed: bool, data: T }
struct MutexARCInner<T: Owned> { lock: Mutex, failed: bool, data: T }
/// An ARC with mutable data protected by a blocking mutex.
struct MutexARC<T: Send> { x: SharedMutableState<MutexARCInner<T>> }
struct MutexARC<T: Owned> { x: SharedMutableState<MutexARCInner<T>> }
/// Create a mutex-protected ARC with the supplied data.
pub fn MutexARC<T: Send>(user_data: T) -> MutexARC<T> {
pub fn MutexARC<T: Owned>(user_data: T) -> MutexARC<T> {
mutex_arc_with_condvars(move 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: Send>(user_data: T,
pub fn mutex_arc_with_condvars<T: Owned>(user_data: T,
num_condvars: uint) -> MutexARC<T> {
let data =
MutexARCInner { lock: mutex_with_condvars(num_condvars),
@ -144,7 +144,7 @@ pub fn mutex_arc_with_condvars<T: Send>(user_data: T,
MutexARC { x: unsafe { shared_mutable_state(move data) } }
}
impl<T: Send> MutexARC<T>: Clone {
impl<T: Owned> MutexARC<T>: Clone {
/// Duplicate a mutex-protected ARC, as arc::clone.
fn clone(&self) -> MutexARC<T> {
// NB: Cloning the underlying mutex is not necessary. Its reference
@ -153,7 +153,7 @@ impl<T: Send> MutexARC<T>: Clone {
}
}
impl<T: Send> &MutexARC<T> {
impl<T: Owned> &MutexARC<T> {
/**
* Access the underlying mutable data with mutual exclusion from other
@ -210,7 +210,7 @@ impl<T: Send> &MutexARC<T> {
* Will additionally fail if another task has failed while accessing the arc.
*/
// FIXME(#3724) make this a by-move method on the arc
pub fn unwrap_mutex_arc<T: Send>(arc: MutexARC<T>) -> T {
pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T {
let MutexARC { x: x } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let MutexARCInner { failed: failed, data: data, _ } = move inner;
@ -256,27 +256,27 @@ fn PoisonOnFail(failed: &r/mut bool) -> PoisonOnFail/&r {
****************************************************************************/
#[doc(hidden)]
struct RWARCInner<T: Const Send> { lock: RWlock, failed: bool, data: T }
struct RWARCInner<T: Const Owned> { lock: RWlock, failed: bool, data: T }
/**
* A dual-mode ARC protected by a reader-writer lock. The data can be accessed
* mutably or immutably, and immutably-accessing tasks may run concurrently.
*
* Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested.
*/
struct RWARC<T: Const Send> {
struct RWARC<T: Const Owned> {
x: SharedMutableState<RWARCInner<T>>,
mut cant_nest: ()
}
/// Create a reader/writer ARC with the supplied data.
pub fn RWARC<T: Const Send>(user_data: T) -> RWARC<T> {
pub fn RWARC<T: Const Owned>(user_data: T) -> RWARC<T> {
rw_arc_with_condvars(move 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: Const Send>(user_data: T,
pub fn rw_arc_with_condvars<T: Const Owned>(user_data: T,
num_condvars: uint) -> RWARC<T> {
let data =
RWARCInner { lock: rwlock_with_condvars(num_condvars),
@ -284,7 +284,7 @@ pub fn rw_arc_with_condvars<T: Const Send>(user_data: T,
RWARC { x: unsafe { shared_mutable_state(move data) }, cant_nest: () }
}
impl<T: Const Send> RWARC<T> {
impl<T: Const Owned> RWARC<T> {
/// Duplicate a rwlock-protected ARC, as arc::clone.
fn clone(&self) -> RWARC<T> {
RWARC { x: unsafe { clone_shared_mutable_state(&self.x) },
@ -293,7 +293,7 @@ impl<T: Const Send> RWARC<T> {
}
impl<T: Const Send> &RWARC<T> {
impl<T: Const Owned> &RWARC<T> {
/**
* Access the underlying data mutably. Locks the rwlock in write mode;
* other readers and writers will block.
@ -394,7 +394,7 @@ impl<T: Const Send> &RWARC<T> {
* in write mode.
*/
// FIXME(#3724) make this a by-move method on the arc
pub fn unwrap_rw_arc<T: Const Send>(arc: RWARC<T>) -> T {
pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T {
let RWARC { x: x, _ } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let RWARCInner { failed: failed, data: data, _ } = move inner;
@ -408,19 +408,19 @@ pub fn unwrap_rw_arc<T: Const Send>(arc: RWARC<T>) -> 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: Const Send>(state: &r/mut RWARCInner<T>) -> &r/RWlock {
fn borrow_rwlock<T: Const Owned>(state: &r/mut RWARCInner<T>) -> &r/RWlock {
unsafe { cast::transmute_immut(&mut state.lock) }
}
// FIXME (#3154) ice with struct/&<T> prevents these from being structs.
/// The "write permission" token used for RWARC.write_downgrade().
pub enum RWWriteMode<T: Const Send> =
pub enum RWWriteMode<T: Const Owned> =
(&mut T, sync::RWlockWriteMode, PoisonOnFail);
/// The "read permission" token used for RWARC.write_downgrade().
pub enum RWReadMode<T:Const Send> = (&T, sync::RWlockReadMode);
pub enum RWReadMode<T:Const Owned> = (&T, sync::RWlockReadMode);
impl<T: Const Send> &RWWriteMode<T> {
impl<T: Const Owned> &RWWriteMode<T> {
/// Access the pre-downgrade RWARC in write mode.
fn write<U>(blk: fn(x: &mut T) -> U) -> U {
match *self {
@ -446,7 +446,7 @@ impl<T: Const Send> &RWWriteMode<T> {
}
}
impl<T: Const Send> &RWReadMode<T> {
impl<T: Const Owned> &RWReadMode<T> {
/// Access the post-downgrade rwlock in read mode.
fn read<U>(blk: fn(x: &T) -> U) -> U {
match *self {

View File

@ -21,24 +21,24 @@ use pipes::{GenericChan, GenericSmartChan, GenericPort,
Chan, Port, Selectable, Peekable};
/// An extension of `pipes::stream` that allows both sending and receiving.
pub struct DuplexStream<T: Send, U: Send> {
pub struct DuplexStream<T: Owned, U: Owned> {
priv chan: Chan<T>,
priv port: Port<U>,
}
impl<T: Send, U: Send> DuplexStream<T, U> : GenericChan<T> {
impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericChan<T> {
fn send(x: T) {
self.chan.send(move x)
}
}
impl<T: Send, U: Send> DuplexStream<T, U> : GenericSmartChan<T> {
impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericSmartChan<T> {
fn try_send(x: T) -> bool {
self.chan.try_send(move x)
}
}
impl<T: Send, U: Send> DuplexStream<T, U> : GenericPort<U> {
impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericPort<U> {
fn recv() -> U {
self.port.recv()
}
@ -48,20 +48,20 @@ impl<T: Send, U: Send> DuplexStream<T, U> : GenericPort<U> {
}
}
impl<T: Send, U: Send> DuplexStream<T, U> : Peekable<U> {
impl<T: Owned, U: Owned> DuplexStream<T, U> : Peekable<U> {
pure fn peek() -> bool {
self.port.peek()
}
}
impl<T: Send, U: Send> DuplexStream<T, U> : Selectable {
impl<T: Owned, U: Owned> DuplexStream<T, U> : Selectable {
pure fn header() -> *pipes::PacketHeader {
self.port.header()
}
}
/// Creates a bidirectional stream.
pub fn DuplexStream<T: Send, U: Send>()
pub fn DuplexStream<T: Owned, U: Owned>()
-> (DuplexStream<T, U>, DuplexStream<U, T>)
{
let (p1, c2) = pipes::stream();

View File

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

View File

@ -29,7 +29,7 @@ const 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 Send, B: Copy Send>(
fn map_slices<A: Copy Owned, B: Copy Owned>(
xs: &[A],
f: fn() -> fn~(uint, v: &[A]) -> B)
-> ~[B] {
@ -84,7 +84,8 @@ fn map_slices<A: Copy Send, B: Copy Send>(
}
/// A parallel version of map.
pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], f: fn~((&A)) -> B) -> ~[B] {
pub fn map<A: Copy Owned, B: Copy Owned>(
xs: &[A], f: fn~((&A)) -> B) -> ~[B] {
vec::concat(map_slices(xs, || {
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
vec::map(slice, |x| f(x))
@ -93,7 +94,7 @@ pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], f: fn~((&A)) -> B) -> ~[B] {
}
/// A parallel version of mapi.
pub fn mapi<A: Copy Send, B: Copy Send>(xs: &[A],
pub fn mapi<A: Copy Owned, B: Copy Owned>(xs: &[A],
f: fn~(uint, (&A)) -> B) -> ~[B] {
let slices = map_slices(xs, || {
fn~(base: uint, slice : &[A], copy f) -> ~[B] {
@ -114,7 +115,7 @@ pub fn mapi<A: Copy Send, B: Copy Send>(xs: &[A],
* In this case, f is a function that creates functions to run over the
* inner elements. This is to skirt the need for copy constructors.
*/
pub fn mapi_factory<A: Copy Send, B: Copy Send>(
pub fn mapi_factory<A: Copy Owned, B: Copy Owned>(
xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] {
let slices = map_slices(xs, || {
let f = f();
@ -131,7 +132,7 @@ pub fn mapi_factory<A: Copy Send, B: Copy Send>(
}
/// Returns true if the function holds for all elements in the vector.
pub fn alli<A: Copy Send>(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool {
pub fn alli<A: Copy Owned>(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool {
do vec::all(map_slices(xs, || {
fn~(base: uint, slice : &[A], copy f) -> bool {
vec::alli(slice, |i, x| {
@ -142,7 +143,7 @@ pub fn alli<A: Copy Send>(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool {
}
/// Returns true if the function holds for any elements in the vector.
pub fn any<A: Copy Send>(xs: &[A], f: fn~(&(A)) -> bool) -> bool {
pub fn any<A: Copy Owned>(xs: &[A], f: fn~(&(A)) -> bool) -> bool {
do vec::any(map_slices(xs, || {
fn~(_base : uint, slice: &[A], copy f) -> bool {
vec::any(slice, |x| f(x))

View File

@ -76,10 +76,10 @@ struct SemInner<Q> {
blocked: Q
}
#[doc(hidden)]
enum Sem<Q: Send> = Exclusive<SemInner<Q>>;
enum Sem<Q: Owned> = Exclusive<SemInner<Q>>;
#[doc(hidden)]
fn new_sem<Q: Send>(count: int, q: Q) -> Sem<Q> {
fn new_sem<Q: Owned>(count: int, q: Q) -> Sem<Q> {
Sem(exclusive(SemInner {
mut count: count, waiters: new_waitqueue(), blocked: move q }))
}
@ -94,7 +94,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
}
#[doc(hidden)]
impl<Q: Send> &Sem<Q> {
impl<Q: Owned> &Sem<Q> {
fn acquire() {
let mut waiter_nobe = None;
unsafe {
@ -160,9 +160,9 @@ impl &Sem<~[mut Waitqueue]> {
#[doc(hidden)]
type SemRelease = SemReleaseGeneric<()>;
type SemAndSignalRelease = SemReleaseGeneric<~[mut Waitqueue]>;
struct SemReleaseGeneric<Q: Send> { sem: &Sem<Q> }
struct SemReleaseGeneric<Q: Owned> { sem: &Sem<Q> }
impl<Q: Send> SemReleaseGeneric<Q> : Drop {
impl<Q: Owned> SemReleaseGeneric<Q> : Drop {
fn finalize(&self) {
self.sem.release();
}

View File

@ -32,7 +32,7 @@ use comm = core::comm;
* * 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: Send>(iotask: IoTask,
pub fn delayed_send<T: Owned>(iotask: IoTask,
msecs: uint, ch: comm::Chan<T>, val: T) {
unsafe {
let timer_done_po = core::comm::Port::<()>();
@ -108,7 +108,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 Send>(iotask: IoTask,
pub fn recv_timeout<T: Copy Owned>(iotask: IoTask,
msecs: uint,
wait_po: comm::Port<T>) -> Option<T> {
let timeout_po = comm::Port::<()>();

View File

@ -166,7 +166,7 @@ struct Exec {
discovered_outputs: WorkMap
}
struct Work<T:Send> {
struct Work<T:Owned> {
prep: @mut Prep,
res: Option<Either<T,PortOne<(Exec,T)>>>
}
@ -197,7 +197,7 @@ impl Context {
Context {db: db, logger: lg, cfg: cfg, freshness: LinearMap()}
}
fn prep<T:Send
fn prep<T:Owned
Serializable<json::Serializer>
Deserializable<json::Deserializer>>(
@self,
@ -245,7 +245,7 @@ impl Prep {
return true;
}
fn exec<T:Send
fn exec<T:Owned
Serializable<json::Serializer>
Deserializable<json::Deserializer>>(
@mut self, blk: ~fn(&Exec) -> T) -> Work<T> {
@ -291,7 +291,7 @@ impl Prep {
}
}
impl<T:Send
impl<T:Owned
Serializable<json::Serializer>
Deserializable<json::Deserializer>>
Work<T> {
@ -301,7 +301,7 @@ impl<T:Send
}
// FIXME (#3724): movable self. This should be in impl Work.
fn unwrap<T:Send
fn unwrap<T:Owned
Serializable<json::Serializer>
Deserializable<json::Deserializer>>(w: Work<T>) -> T {

View File

@ -14,7 +14,7 @@ export foo;
use core::comm::*;
fn foo<T: Send Copy>(x: T) -> Port<T> {
fn foo<T: Owned Copy>(x: T) -> Port<T> {
let p = Port();
let c = Chan(&p);
do task::spawn() |copy c, copy x| {

View File

@ -28,20 +28,20 @@ export recv;
* transmitted. If a port value is copied, both copies refer to the same
* port. Ports may be associated with multiple `chan`s.
*/
enum port<T: Send> {
enum port<T: Owned> {
port_t(@port_ptr<T>)
}
/// Constructs a port
fn port<T: Send>() -> port<T> {
fn port<T: Owned>() -> port<T> {
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>() as size_t)))
}
struct port_ptr<T:Send> {
struct port_ptr<T:Owned> {
po: *rust_port,
}
impl<T:Send> port_ptr<T> : Drop {
impl<T:Owned> port_ptr<T> : Drop {
fn finalize(&self) {
unsafe {
debug!("in the port_ptr destructor");
@ -63,7 +63,7 @@ impl<T:Send> port_ptr<T> : Drop {
}
}
fn port_ptr<T: Send>(po: *rust_port) -> port_ptr<T> {
fn port_ptr<T: Owned>(po: *rust_port) -> port_ptr<T> {
debug!("in the port_ptr constructor");
port_ptr {
po: po
@ -74,11 +74,11 @@ fn port_ptr<T: Send>(po: *rust_port) -> port_ptr<T> {
* Receive from a port. If no data is available on the port then the
* task will block until data becomes available.
*/
fn recv<T: Send>(p: port<T>) -> T { recv_((**p).po) }
fn recv<T: Owned>(p: port<T>) -> T { recv_((**p).po) }
/// Receive on a raw port pointer
fn recv_<T: Send>(p: *rust_port) -> T {
fn recv_<T: Owned>(p: *rust_port) -> T {
let yield = 0;
let yieldp = ptr::addr_of(&yield);
let mut res;

View File

@ -68,7 +68,7 @@ macro_rules! follow (
)
)
fn switch<T: Send, Tb: Send, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
fn switch<T: Owned, Tb: Owned, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
f: fn(+v: Option<T>) -> U) -> U {
f(pipes::try_recv(move endp))
}

View File

@ -124,35 +124,35 @@ mod map_reduce {
export reducer;
export map_reduce;
type putter<K: Send, V: Send> = fn(&K, V);
type putter<K: Owned, V: Owned> = fn(&K, V);
type mapper<K1: Send, K2: Send, V: Send> = fn~(K1, putter<K2, V>);
type mapper<K1: Owned, K2: Owned, V: Owned> = fn~(K1, putter<K2, V>);
type getter<V: Send> = fn() -> Option<V>;
type getter<V: Owned> = fn() -> Option<V>;
type reducer<K: Copy Send, V: Copy Send> = fn~(&K, getter<V>);
type reducer<K: Copy Owned, V: Copy Owned> = fn~(&K, getter<V>);
enum ctrl_proto<K: Copy Send, V: Copy Send> {
enum ctrl_proto<K: Copy Owned, V: Copy Owned> {
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
mapper_done
}
proto! ctrl_proto (
open: send<K: Copy Send, V: Copy Send> {
open: send<K: Copy Owned, V: Copy Owned> {
find_reducer(K) -> reducer_response<K, V>,
mapper_done -> !
}
reducer_response: recv<K: Copy Send, V: Copy Send> {
reducer_response: recv<K: Copy Owned, V: Copy Owned> {
reducer(Chan<reduce_proto<V>>) -> open<K, V>
}
)
enum reduce_proto<V: Copy Send> { emit_val(V), done, addref, release }
enum reduce_proto<V: Copy Owned> { emit_val(V), done, addref, release }
fn start_mappers<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send,
V: Copy Send>(
fn start_mappers<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned,
V: Copy Owned>(
map: &mapper<K1, K2, V>,
ctrls: &mut ~[ctrl_proto::server::open<K2, V>],
inputs: &~[K1])
@ -170,7 +170,7 @@ mod map_reduce {
move tasks
}
fn map_task<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
fn map_task<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned, V: Copy Owned>(
map: mapper<K1, K2, V>,
ctrl: &box<ctrl_proto::client::open<K2, V>>,
input: K1)
@ -202,7 +202,7 @@ mod map_reduce {
send(c.get(), emit_val(val));
}
fn finish<K: Copy Send, V: Copy Send>(_k: K, v: Chan<reduce_proto<V>>)
fn finish<K: Copy Owned, V: Copy Owned>(_k: K, v: Chan<reduce_proto<V>>)
{
send(v, release);
}
@ -210,7 +210,7 @@ mod map_reduce {
ctrl_proto::client::mapper_done(ctrl.unwrap());
}
fn reduce_task<K: Copy Send, V: Copy Send>(
fn reduce_task<K: Copy Owned, V: Copy Owned>(
reduce: ~reducer<K, V>,
key: K,
out: Chan<Chan<reduce_proto<V>>>)
@ -222,7 +222,7 @@ mod map_reduce {
let mut ref_count = 0;
let mut is_done = false;
fn get<V: Copy Send>(p: Port<reduce_proto<V>>,
fn get<V: Copy Owned>(p: Port<reduce_proto<V>>,
ref_count: &mut int, is_done: &mut bool)
-> Option<V> {
while !*is_done || *ref_count > 0 {
@ -245,7 +245,7 @@ mod map_reduce {
(*reduce)(&key, || get(p, &mut ref_count, &mut is_done) );
}
fn map_reduce<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
fn map_reduce<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned, V: Copy Owned>(
map: mapper<K1, K2, V>,
reduce: reducer<K2, V>,
inputs: ~[K1])

View File

@ -10,10 +10,10 @@
mod stream {
#[legacy_exports];
enum Stream<T: Send> { send(T, server::Stream<T>), }
enum Stream<T: Owned> { send(T, server::Stream<T>), }
mod server {
#[legacy_exports];
impl<T: Send> Stream<T> {
impl<T: Owned> Stream<T> {
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.
@ -26,7 +26,7 @@ mod stream {
recv
}
}
type Stream<T: Send> = pipes::RecvPacket<stream::Stream<T>>;
type Stream<T: Owned> = pipes::RecvPacket<stream::Stream<T>>;
}
}

View File

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

View File

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

View File

@ -25,7 +25,7 @@ fn foo(i:int, j: @~str) -> foo {
fn main() {
let cat = ~"kitty";
let po = comm::Port(); //~ ERROR missing `send`
let ch = comm::Chan(&po); //~ ERROR missing `send`
comm::send(ch, foo(42, @(move cat))); //~ ERROR missing `send`
let po = comm::Port(); //~ ERROR missing `owned`
let ch = comm::Chan(&po); //~ ERROR missing `owned`
comm::send(ch, foo(42, @(move cat))); //~ ERROR missing `owned`
}

View File

@ -14,8 +14,8 @@ fn test00_start(ch: chan_t<int>, message: int) { send(ch, message); }
type task_id = int;
type port_id = int;
enum chan_t<T: Send> = {task: task_id, port: port_id};
enum chan_t<T: Owned> = {task: task_id, port: port_id};
fn send<T: Send>(ch: chan_t<T>, data: T) { fail; }
fn send<T: Owned>(ch: chan_t<T>, data: T) { fail; }
fn main() { fail ~"quux"; }

View File

@ -13,7 +13,7 @@
extern mod std;
use std::arc;
enum e<T: Const Send> { e(arc::ARC<T>) }
enum e<T: Const Owned> { e(arc::ARC<T>) }
fn foo() -> e<int> {fail;}

View File

@ -15,7 +15,7 @@ use comm::Port;
use comm::send;
use comm::recv;
fn echo<T: Send>(c: Chan<T>, oc: Chan<Chan<T>>) {
fn echo<T: Owned>(c: Chan<T>, oc: Chan<Chan<T>>) {
// Tests that the type argument in port gets
// visited
let p = Port::<T>();

View File

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

View File

@ -11,7 +11,7 @@
fn ignore<T>(_x: T) {}
fn main() {
let f: fn@:Send() = ||();
let f: fn@:Owned() = ||();
ignore(f);
}

View File

@ -11,11 +11,11 @@
// xfail-fast
#[legacy_modes];
fn fix_help<A: Durable, B: Send>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
fn fix_help<A: Durable, B: Owned>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
return f({|a|fix_help(f, a)}, x);
}
fn fix<A: Durable, B: Send>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
fn fix<A: Durable, B: Owned>(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: Send>(val: T, f: extern fn(T)) {
fn spawn<T: Owned>(val: T, f: extern fn(T)) {
f(move val);
}

View File

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

View File

@ -29,13 +29,13 @@ mod pipes {
pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) }
}
type packet<T: Send> = {
type packet<T: Owned> = {
mut state: state,
mut blocked_task: Option<task::Task>,
mut payload: Option<T>
};
fn packet<T: Send>() -> *packet<T> unsafe {
fn packet<T: Owned>() -> *packet<T> unsafe {
let p: *packet<T> = cast::transmute(~{
mut state: empty,
mut blocked_task: None::<task::Task>,
@ -70,7 +70,7 @@ mod pipes {
}
}
fn send<T: Send>(-p: send_packet<T>, -payload: T) {
fn send<T: Owned>(-p: send_packet<T>, -payload: T) {
let p = p.unwrap();
let p = unsafe { uniquify(p) };
assert (*p).payload.is_none();
@ -96,7 +96,7 @@ mod pipes {
}
}
fn recv<T: Send>(-p: recv_packet<T>) -> Option<T> {
fn recv<T: Owned>(-p: recv_packet<T>) -> Option<T> {
let p = p.unwrap();
let p = unsafe { uniquify(p) };
loop {
@ -117,7 +117,7 @@ mod pipes {
}
}
fn sender_terminate<T: Send>(p: *packet<T>) {
fn sender_terminate<T: Owned>(p: *packet<T>) {
let p = unsafe { uniquify(p) };
match swap_state_rel(&mut (*p).state, terminated) {
empty | blocked => {
@ -134,7 +134,7 @@ mod pipes {
}
}
fn receiver_terminate<T: Send>(p: *packet<T>) {
fn receiver_terminate<T: Owned>(p: *packet<T>) {
let p = unsafe { uniquify(p) };
match swap_state_rel(&mut (*p).state, terminated) {
empty => {
@ -151,11 +151,11 @@ mod pipes {
}
}
struct send_packet<T: Send> {
struct send_packet<T: Owned> {
mut p: Option<*packet<T>>,
}
impl<T: Send> send_packet<T> : Drop {
impl<T: Owned> send_packet<T> : Drop {
fn finalize(&self) {
if self.p != None {
let mut p = None;
@ -165,7 +165,7 @@ mod pipes {
}
}
impl<T: Send> send_packet<T> {
impl<T: Owned> send_packet<T> {
fn unwrap() -> *packet<T> {
let mut p = None;
p <-> self.p;
@ -173,17 +173,17 @@ mod pipes {
}
}
fn send_packet<T: Send>(p: *packet<T>) -> send_packet<T> {
fn send_packet<T: Owned>(p: *packet<T>) -> send_packet<T> {
send_packet {
p: Some(p)
}
}
struct recv_packet<T: Send> {
struct recv_packet<T: Owned> {
mut p: Option<*packet<T>>,
}
impl<T: Send> recv_packet<T> : Drop {
impl<T: Owned> recv_packet<T> : Drop {
fn finalize(&self) {
if self.p != None {
let mut p = None;
@ -193,7 +193,7 @@ mod pipes {
}
}
impl<T: Send> recv_packet<T> {
impl<T: Owned> recv_packet<T> {
fn unwrap() -> *packet<T> {
let mut p = None;
p <-> self.p;
@ -201,13 +201,13 @@ mod pipes {
}
}
fn recv_packet<T: Send>(p: *packet<T>) -> recv_packet<T> {
fn recv_packet<T: Owned>(p: *packet<T>) -> recv_packet<T> {
recv_packet {
p: Some(p)
}
}
fn entangle<T: Send>() -> (send_packet<T>, recv_packet<T>) {
fn entangle<T: Owned>() -> (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: Send> {
open:send<T: Owned> {
data(T) -> open<T>
}
)

View File

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

View File

@ -47,7 +47,7 @@ macro_rules! move_it (
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
fn switch<T: Owned, U>(+endp: pipes::RecvPacket<T>,
f: fn(+v: Option<T>) -> U) -> U {
f(pipes::try_recv(move endp))
}

View File

@ -26,7 +26,7 @@ proto! oneshot (
)
proto! stream (
Stream:send<T:Send> {
Stream:send<T:Owned> {
send(T) -> Stream<T>
}
)

View File

@ -9,9 +9,9 @@
// except according to those terms.
// tests that ctrl's type gets inferred properly
type command<K: Send, V: Send> = {key: K, val: V};
type command<K: Owned, V: Owned> = {key: K, val: V};
fn cache_server<K: Send, V: Send>(c: core::comm::Chan<core::comm::Chan<command<K, V>>>) {
fn cache_server<K: Owned, V: Owned>(c: core::comm::Chan<core::comm::Chan<command<K, V>>>) {
let ctrl = core::comm::Port();
core::comm::send(c, core::comm::Chan(&ctrl));
}

View File

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

View File

@ -18,7 +18,7 @@ type pointy = {
d : fn~() -> uint,
};
fn make_uniq_closure<A:Send Copy>(a: A) -> fn~() -> uint {
fn make_uniq_closure<A:Owned Copy>(a: A) -> fn~() -> uint {
fn~() -> uint { ptr::addr_of(&a) as uint }
}

View File

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