Make moves explicit in arguments
This commit is contained in:
parent
2c6c963f61
commit
c087886e93
23 changed files with 113 additions and 109 deletions
|
@ -177,7 +177,7 @@ mod unsafe {
|
||||||
(**repr).fill += sys::size_of::<T>();
|
(**repr).fill += sys::size_of::<T>();
|
||||||
let p = ptr::addr_of((**repr).data);
|
let p = ptr::addr_of((**repr).data);
|
||||||
let p = ptr::offset(p, fill) as *mut T;
|
let p = ptr::offset(p, fill) as *mut T;
|
||||||
rusti::move_val_init(*p, initval);
|
rusti::move_val_init(*p, move initval);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn push_slow<T>(&v: @[const T], +initval: T) {
|
unsafe fn push_slow<T>(&v: @[const T], +initval: T) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ fn send<T: Send>(ch: Chan<T>, +data: T) {
|
||||||
let res = rustrt::rust_port_id_send(p, data_ptr);
|
let res = rustrt::rust_port_id_send(p, data_ptr);
|
||||||
if res != 0 unsafe {
|
if res != 0 unsafe {
|
||||||
// Data sent successfully
|
// Data sent successfully
|
||||||
unsafe::forget(data);
|
unsafe::forget(move data);
|
||||||
}
|
}
|
||||||
task::yield();
|
task::yield();
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,27 +198,27 @@ impl<T> DList<T> {
|
||||||
|
|
||||||
/// Add data to the head of the list. O(1).
|
/// Add data to the head of the list. O(1).
|
||||||
fn push_head(+data: T) {
|
fn push_head(+data: T) {
|
||||||
self.add_head(self.new_link(data));
|
self.add_head(self.new_link(move data));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add data to the head of the list, and get the new containing
|
* Add data to the head of the list, and get the new containing
|
||||||
* node. O(1).
|
* node. O(1).
|
||||||
*/
|
*/
|
||||||
fn push_head_n(+data: T) -> DListNode<T> {
|
fn push_head_n(+data: T) -> DListNode<T> {
|
||||||
let mut nobe = self.new_link(data);
|
let mut nobe = self.new_link(move data);
|
||||||
self.add_head(nobe);
|
self.add_head(nobe);
|
||||||
option::get(nobe)
|
option::get(nobe)
|
||||||
}
|
}
|
||||||
/// Add data to the tail of the list. O(1).
|
/// Add data to the tail of the list. O(1).
|
||||||
fn push(+data: T) {
|
fn push(+data: T) {
|
||||||
self.add_tail(self.new_link(data));
|
self.add_tail(self.new_link(move data));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add data to the tail of the list, and get the new containing
|
* Add data to the tail of the list, and get the new containing
|
||||||
* node. O(1).
|
* node. O(1).
|
||||||
*/
|
*/
|
||||||
fn push_n(+data: T) -> DListNode<T> {
|
fn push_n(+data: T) -> DListNode<T> {
|
||||||
let mut nobe = self.new_link(data);
|
let mut nobe = self.new_link(move data);
|
||||||
self.add_tail(nobe);
|
self.add_tail(nobe);
|
||||||
option::get(nobe)
|
option::get(nobe)
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ impl<T> DList<T> {
|
||||||
* O(1).
|
* O(1).
|
||||||
*/
|
*/
|
||||||
fn insert_before(+data: T, neighbour: DListNode<T>) {
|
fn insert_before(+data: T, neighbour: DListNode<T>) {
|
||||||
self.insert_left(self.new_link(data), neighbour);
|
self.insert_left(self.new_link(move data), neighbour);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Insert an existing node in the middle of the list, left of the
|
* Insert an existing node in the middle of the list, left of the
|
||||||
|
@ -242,7 +242,7 @@ impl<T> DList<T> {
|
||||||
* and get its containing node. O(1).
|
* and get its containing node. O(1).
|
||||||
*/
|
*/
|
||||||
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
|
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
|
||||||
let mut nobe = self.new_link(data);
|
let mut nobe = self.new_link(move data);
|
||||||
self.insert_left(nobe, neighbour);
|
self.insert_left(nobe, neighbour);
|
||||||
option::get(nobe)
|
option::get(nobe)
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ impl<T> DList<T> {
|
||||||
* O(1).
|
* O(1).
|
||||||
*/
|
*/
|
||||||
fn insert_after(+data: T, neighbour: DListNode<T>) {
|
fn insert_after(+data: T, neighbour: DListNode<T>) {
|
||||||
self.insert_right(neighbour, self.new_link(data));
|
self.insert_right(neighbour, self.new_link(move data));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Insert an existing node in the middle of the list, right of the
|
* Insert an existing node in the middle of the list, right of the
|
||||||
|
@ -266,7 +266,7 @@ impl<T> DList<T> {
|
||||||
* and get its containing node. O(1).
|
* and get its containing node. O(1).
|
||||||
*/
|
*/
|
||||||
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
|
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
|
||||||
let mut nobe = self.new_link(data);
|
let mut nobe = self.new_link(move data);
|
||||||
self.insert_right(neighbour, nobe);
|
self.insert_right(neighbour, nobe);
|
||||||
option::get(nobe)
|
option::get(nobe)
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ priv impl<A> DVec<A> {
|
||||||
data <-> self.data;
|
data <-> self.data;
|
||||||
let data_ptr: *() = unsafe::reinterpret_cast(&data);
|
let data_ptr: *() = unsafe::reinterpret_cast(&data);
|
||||||
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
|
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
|
||||||
return f(data);
|
return f(move data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ impl<A> DVec<A> {
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
|
fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
|
||||||
self.check_out(|v| self.give_back(f(v)))
|
self.check_out(|v| self.give_back(f(move v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of elements currently in the dvec
|
/// Returns the number of elements currently in the dvec
|
||||||
|
@ -131,7 +131,7 @@ impl<A> DVec<A> {
|
||||||
unchecked {
|
unchecked {
|
||||||
do self.check_out |v| {
|
do self.check_out |v| {
|
||||||
let l = v.len();
|
let l = v.len();
|
||||||
self.give_back(v);
|
self.give_back(move v);
|
||||||
l
|
l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ impl<A> DVec<A> {
|
||||||
do self.check_out |v| {
|
do self.check_out |v| {
|
||||||
let mut v <- v;
|
let mut v <- v;
|
||||||
let result = vec::pop(v);
|
let result = vec::pop(v);
|
||||||
self.give_back(v);
|
self.give_back(move v);
|
||||||
move result
|
move result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ impl<A> DVec<A> {
|
||||||
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
|
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
|
||||||
log(error, ~"a");
|
log(error, ~"a");
|
||||||
self.data <- ~[mut move t];
|
self.data <- ~[mut move t];
|
||||||
vec::push_all_move(self.data, data);
|
vec::push_all_move(self.data, move data);
|
||||||
log(error, ~"b");
|
log(error, ~"b");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ impl<A> DVec<A> {
|
||||||
fn reverse() {
|
fn reverse() {
|
||||||
do self.check_out |v| {
|
do self.check_out |v| {
|
||||||
vec::reverse(v);
|
vec::reverse(v);
|
||||||
self.give_back(v);
|
self.give_back(move v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ impl<A> DVec<A> {
|
||||||
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
|
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
|
||||||
do self.check_out |v| {
|
do self.check_out |v| {
|
||||||
let result = op(v);
|
let result = op(v);
|
||||||
self.give_back(v);
|
self.give_back(move v);
|
||||||
move result
|
move result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ impl<A> DVec<A> {
|
||||||
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
|
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
|
||||||
do self.check_out |v| {
|
do self.check_out |v| {
|
||||||
let result = op(v);
|
let result = op(v);
|
||||||
self.give_back(v);
|
self.give_back(move v);
|
||||||
move result
|
move result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ impl<A: Copy> DVec<A> {
|
||||||
unchecked {
|
unchecked {
|
||||||
do self.check_out |v| {
|
do self.check_out |v| {
|
||||||
let w = vec::from_mut(copy v);
|
let w = vec::from_mut(copy v);
|
||||||
self.give_back(v);
|
self.give_back(move v);
|
||||||
move w
|
move w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
|
||||||
do from_fn |move port| {
|
do from_fn |move port| {
|
||||||
let mut port_ = None;
|
let mut port_ = None;
|
||||||
port_ <-> *port;
|
port_ <-> *port;
|
||||||
let port = option::unwrap(port_);
|
let port = option::unwrap(move port_);
|
||||||
match recv(move port) {
|
match recv(move port) {
|
||||||
future_pipe::completed(move data) => move data
|
future_pipe::completed(move data) => move data
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+T) -> U) -> Option<U> {
|
||||||
* As `map`, but consumes the option and gives `f` ownership to avoid
|
* As `map`, but consumes the option and gives `f` ownership to avoid
|
||||||
* copying.
|
* copying.
|
||||||
*/
|
*/
|
||||||
if opt.is_some() { Some(f(option::unwrap(opt))) } else { None }
|
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn chain<T, U>(opt: Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
|
pure fn chain<T, U>(opt: Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
|
||||||
|
@ -112,7 +112,7 @@ pure fn while_some<T>(+x: Option<T>, blk: fn(+T) -> Option<T>) {
|
||||||
|
|
||||||
let mut opt <- x;
|
let mut opt <- x;
|
||||||
while opt.is_some() {
|
while opt.is_some() {
|
||||||
opt = blk(unwrap(opt));
|
opt = blk(unwrap(move opt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
|
||||||
pure fn unwrap_expect<T>(+opt: Option<T>, reason: &str) -> T {
|
pure fn unwrap_expect<T>(+opt: Option<T>, reason: &str) -> T {
|
||||||
//! As unwrap, but with a specified failure message.
|
//! As unwrap, but with a specified failure message.
|
||||||
if opt.is_none() { fail reason.to_unique(); }
|
if opt.is_none() { fail reason.to_unique(); }
|
||||||
unwrap(opt)
|
unwrap(move opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some of these should change to be &Option<T>, some should not. See below.
|
// Some of these should change to be &Option<T>, some should not. See below.
|
||||||
|
|
|
@ -272,7 +272,7 @@ fn packet<T: Send>() -> *Packet<T> {
|
||||||
let b = unibuffer();
|
let b = unibuffer();
|
||||||
let p = ptr::addr_of(b.data);
|
let p = ptr::addr_of(b.data);
|
||||||
// We'll take over memory management from here.
|
// We'll take over memory management from here.
|
||||||
unsafe { forget(b) }
|
unsafe { forget(move b) }
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ fn entangle_buffer<T: Send, Tstart: Send>(
|
||||||
-> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>)
|
-> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>)
|
||||||
{
|
{
|
||||||
let p = init(unsafe { reinterpret_cast(&buffer) }, &buffer.data);
|
let p = init(unsafe { reinterpret_cast(&buffer) }, &buffer.data);
|
||||||
unsafe { forget(buffer) }
|
unsafe { forget(move buffer) }
|
||||||
(SendPacketBuffered(p), RecvPacketBuffered(p))
|
(SendPacketBuffered(p), RecvPacketBuffered(p))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ fn swap_task(+dst: &mut *rust_task, src: *rust_task) -> *rust_task {
|
||||||
// It might be worth making both acquire and release versions of
|
// It might be worth making both acquire and release versions of
|
||||||
// this.
|
// this.
|
||||||
unsafe {
|
unsafe {
|
||||||
transmute(rusti::atomic_xchg(transmute(dst), src as int))
|
transmute(rusti::atomic_xchg(transmute(move dst), src as int))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,14 +357,14 @@ fn wait_event(this: *rust_task) -> *libc::c_void {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn swap_state_acq(+dst: &mut State, src: State) -> State {
|
fn swap_state_acq(+dst: &mut State, src: State) -> State {
|
||||||
unsafe {
|
unsafe {
|
||||||
transmute(rusti::atomic_xchg_acq(transmute(dst), src as int))
|
transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn swap_state_rel(+dst: &mut State, src: State) -> State {
|
fn swap_state_rel(+dst: &mut State, src: State) -> State {
|
||||||
unsafe {
|
unsafe {
|
||||||
transmute(rusti::atomic_xchg_rel(transmute(dst), src as int))
|
transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ struct BufferResource<T: Send> {
|
||||||
// go go gadget drop glue
|
// go go gadget drop glue
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
forget(b)
|
forget(move b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ fn try_recv<T: Send, Tbuffer: Send>(+p: RecvPacketBuffered<T, Tbuffer>)
|
||||||
let mut payload = None;
|
let mut payload = None;
|
||||||
payload <-> p.payload;
|
payload <-> p.payload;
|
||||||
p.header.state = Empty;
|
p.header.state = Empty;
|
||||||
return Some(option::unwrap(payload))
|
return Some(option::unwrap(move payload))
|
||||||
},
|
},
|
||||||
Terminated => return None,
|
Terminated => return None,
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -534,7 +534,7 @@ fn try_recv<T: Send, Tbuffer: Send>(+p: RecvPacketBuffered<T, Tbuffer>)
|
||||||
rustrt::rust_task_deref(old_task);
|
rustrt::rust_task_deref(old_task);
|
||||||
}
|
}
|
||||||
p.header.state = Empty;
|
p.header.state = Empty;
|
||||||
return Some(option::unwrap(payload))
|
return Some(option::unwrap(move payload))
|
||||||
}
|
}
|
||||||
Terminated => {
|
Terminated => {
|
||||||
// This assert detects when we've accidentally unsafely
|
// This assert detects when we've accidentally unsafely
|
||||||
|
@ -789,7 +789,7 @@ struct SendPacketBuffered<T: Send, Tbuffer: Send> {
|
||||||
if self.p != None {
|
if self.p != None {
|
||||||
let mut p = None;
|
let mut p = None;
|
||||||
p <-> self.p;
|
p <-> self.p;
|
||||||
sender_terminate(option::unwrap(p))
|
sender_terminate(option::unwrap(move p))
|
||||||
}
|
}
|
||||||
//unsafe { error!("send_drop: %?",
|
//unsafe { error!("send_drop: %?",
|
||||||
// if self.buffer == none {
|
// if self.buffer == none {
|
||||||
|
@ -814,7 +814,7 @@ impl<T: Send, Tbuffer: Send> SendPacketBuffered<T, Tbuffer> {
|
||||||
fn unwrap() -> *Packet<T> {
|
fn unwrap() -> *Packet<T> {
|
||||||
let mut p = None;
|
let mut p = None;
|
||||||
p <-> self.p;
|
p <-> self.p;
|
||||||
option::unwrap(p)
|
option::unwrap(move p)
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn header() -> *PacketHeader {
|
pure fn header() -> *PacketHeader {
|
||||||
|
@ -833,7 +833,7 @@ impl<T: Send, Tbuffer: Send> SendPacketBuffered<T, Tbuffer> {
|
||||||
//error!("send reuse_buffer");
|
//error!("send reuse_buffer");
|
||||||
let mut tmp = None;
|
let mut tmp = None;
|
||||||
tmp <-> self.buffer;
|
tmp <-> self.buffer;
|
||||||
option::unwrap(tmp)
|
option::unwrap(move tmp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ struct RecvPacketBuffered<T: Send, Tbuffer: Send> {
|
||||||
if self.p != None {
|
if self.p != None {
|
||||||
let mut p = None;
|
let mut p = None;
|
||||||
p <-> self.p;
|
p <-> self.p;
|
||||||
receiver_terminate(option::unwrap(p))
|
receiver_terminate(option::unwrap(move p))
|
||||||
}
|
}
|
||||||
//unsafe { error!("recv_drop: %?",
|
//unsafe { error!("recv_drop: %?",
|
||||||
// if self.buffer == none {
|
// if self.buffer == none {
|
||||||
|
@ -886,7 +886,7 @@ impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> : Selectable {
|
||||||
fn unwrap() -> *Packet<T> {
|
fn unwrap() -> *Packet<T> {
|
||||||
let mut p = None;
|
let mut p = None;
|
||||||
p <-> self.p;
|
p <-> self.p;
|
||||||
option::unwrap(p)
|
option::unwrap(move p)
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn header() -> *PacketHeader {
|
pure fn header() -> *PacketHeader {
|
||||||
|
@ -905,7 +905,7 @@ impl<T: Send, Tbuffer: Send> RecvPacketBuffered<T, Tbuffer> : Selectable {
|
||||||
//error!("recv reuse_buffer");
|
//error!("recv reuse_buffer");
|
||||||
let mut tmp = None;
|
let mut tmp = None;
|
||||||
tmp <-> self.buffer;
|
tmp <-> self.buffer;
|
||||||
option::unwrap(tmp)
|
option::unwrap(move tmp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,7 +954,7 @@ fn spawn_service<T: Send, Tb: Send>(
|
||||||
do task::spawn |move service, move server| {
|
do task::spawn |move service, move server| {
|
||||||
let mut server_ = None;
|
let mut server_ = None;
|
||||||
server_ <-> *server;
|
server_ <-> *server;
|
||||||
service(option::unwrap(server_))
|
service(option::unwrap(move server_))
|
||||||
}
|
}
|
||||||
|
|
||||||
move client
|
move client
|
||||||
|
@ -978,7 +978,7 @@ fn spawn_service_recv<T: Send, Tb: Send>(
|
||||||
do task::spawn |move service, move server| {
|
do task::spawn |move service, move server| {
|
||||||
let mut server_ = None;
|
let mut server_ = None;
|
||||||
server_ <-> *server;
|
server_ <-> *server;
|
||||||
service(option::unwrap(server_))
|
service(option::unwrap(move server_))
|
||||||
}
|
}
|
||||||
|
|
||||||
move client
|
move client
|
||||||
|
@ -1054,13 +1054,13 @@ impl<T: Send> Chan<T>: Channel<T> {
|
||||||
let mut endp = None;
|
let mut endp = None;
|
||||||
endp <-> self.endp;
|
endp <-> self.endp;
|
||||||
self.endp = Some(
|
self.endp = Some(
|
||||||
streamp::client::data(unwrap(endp), move x))
|
streamp::client::data(unwrap(move endp), move x))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_send(+x: T) -> bool {
|
fn try_send(+x: T) -> bool {
|
||||||
let mut endp = None;
|
let mut endp = None;
|
||||||
endp <-> self.endp;
|
endp <-> self.endp;
|
||||||
match move streamp::client::try_data(unwrap(endp), move x) {
|
match move streamp::client::try_data(unwrap(move endp), move x) {
|
||||||
Some(move next) => {
|
Some(move next) => {
|
||||||
self.endp = Some(move next);
|
self.endp = Some(move next);
|
||||||
true
|
true
|
||||||
|
@ -1074,7 +1074,7 @@ impl<T: Send> Port<T>: Recv<T> {
|
||||||
fn recv() -> T {
|
fn recv() -> T {
|
||||||
let mut endp = None;
|
let mut endp = None;
|
||||||
endp <-> self.endp;
|
endp <-> self.endp;
|
||||||
let streamp::data(x, endp) = pipes::recv(unwrap(endp));
|
let streamp::data(x, endp) = pipes::recv(unwrap(move endp));
|
||||||
self.endp = Some(move endp);
|
self.endp = Some(move endp);
|
||||||
move x
|
move x
|
||||||
}
|
}
|
||||||
|
@ -1082,7 +1082,7 @@ impl<T: Send> Port<T>: Recv<T> {
|
||||||
fn try_recv() -> Option<T> {
|
fn try_recv() -> Option<T> {
|
||||||
let mut endp = None;
|
let mut endp = None;
|
||||||
endp <-> self.endp;
|
endp <-> self.endp;
|
||||||
match move pipes::try_recv(unwrap(endp)) {
|
match move pipes::try_recv(unwrap(move endp)) {
|
||||||
Some(streamp::data(move x, move endp)) => {
|
Some(streamp::data(move x, move endp)) => {
|
||||||
self.endp = Some(move endp);
|
self.endp = Some(move endp);
|
||||||
Some(move x)
|
Some(move x)
|
||||||
|
@ -1180,7 +1180,7 @@ impl<T: Send> SharedChan<T>: Channel<T> {
|
||||||
do self.with |chan| {
|
do self.with |chan| {
|
||||||
let mut x = None;
|
let mut x = None;
|
||||||
x <-> xx;
|
x <-> xx;
|
||||||
chan.send(option::unwrap(x))
|
chan.send(option::unwrap(move x))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1189,7 @@ impl<T: Send> SharedChan<T>: Channel<T> {
|
||||||
do self.with |chan| {
|
do self.with |chan| {
|
||||||
let mut x = None;
|
let mut x = None;
|
||||||
x <-> xx;
|
x <-> xx;
|
||||||
chan.try_send(option::unwrap(x))
|
chan.try_send(option::unwrap(move x))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1260,7 +1260,7 @@ fn try_recv_one<T: Send> (+port: PortOne<T>) -> Option<T> {
|
||||||
|
|
||||||
if message.is_none() { None }
|
if message.is_none() { None }
|
||||||
else {
|
else {
|
||||||
let oneshot::send(message) = option::unwrap(message);
|
let oneshot::send(message) = option::unwrap(move message);
|
||||||
Some(move message)
|
Some(move message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ mod linear {
|
||||||
if value.is_none() {
|
if value.is_none() {
|
||||||
fail fmt!("No entry found for key: %?", k);
|
fail fmt!("No entry found for key: %?", k);
|
||||||
}
|
}
|
||||||
option::unwrap(value)
|
option::unwrap(move value)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,8 +149,7 @@ pure fn from_slice(s: &str) -> ~str {
|
||||||
*/
|
*/
|
||||||
pure fn from_byte(b: u8) -> ~str {
|
pure fn from_byte(b: u8) -> ~str {
|
||||||
assert b < 128u8;
|
assert b < 128u8;
|
||||||
let mut v = ~[b, 0u8];
|
unsafe { ::unsafe::transmute(~[b, 0u8]) }
|
||||||
unsafe { ::unsafe::transmute(v) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Appends a character at the end of a string
|
/// Appends a character at the end of a string
|
||||||
|
@ -437,8 +436,7 @@ Section: Transforming strings
|
||||||
* The result vector is not null-terminated.
|
* The result vector is not null-terminated.
|
||||||
*/
|
*/
|
||||||
pure fn to_bytes(s: &str) -> ~[u8] unsafe {
|
pure fn to_bytes(s: &str) -> ~[u8] unsafe {
|
||||||
let mut s_copy = from_slice(s);
|
let mut v: ~[u8] = ::unsafe::transmute(from_slice(s));
|
||||||
let mut v: ~[u8] = ::unsafe::transmute(s_copy);
|
|
||||||
vec::unsafe::set_len(v, len(s));
|
vec::unsafe::set_len(v, len(s));
|
||||||
move v
|
move v
|
||||||
}
|
}
|
||||||
|
@ -1997,7 +1995,7 @@ mod unsafe {
|
||||||
vec::push(v, 0u8);
|
vec::push(v, 0u8);
|
||||||
|
|
||||||
assert is_utf8(v);
|
assert is_utf8(v);
|
||||||
return ::unsafe::transmute(v);
|
return ::unsafe::transmute(move v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a Rust string from a *u8 buffer of the given length
|
/// Create a Rust string from a *u8 buffer of the given length
|
||||||
|
@ -2005,7 +2003,7 @@ mod unsafe {
|
||||||
unsafe fn from_buf_len_nocopy(buf: &a / *u8, len: uint) -> &a / str {
|
unsafe fn from_buf_len_nocopy(buf: &a / *u8, len: uint) -> &a / str {
|
||||||
let v = (*buf, len + 1);
|
let v = (*buf, len + 1);
|
||||||
assert is_utf8(::unsafe::reinterpret_cast(&v));
|
assert is_utf8(::unsafe::reinterpret_cast(&v));
|
||||||
return ::unsafe::transmute(v);
|
return ::unsafe::transmute(move v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a Rust string from a null-terminated C string
|
/// Create a Rust string from a null-terminated C string
|
||||||
|
@ -2052,7 +2050,7 @@ mod unsafe {
|
||||||
}
|
}
|
||||||
vec::unsafe::set_len(v, end - begin);
|
vec::unsafe::set_len(v, end - begin);
|
||||||
vec::push(v, 0u8);
|
vec::push(v, 0u8);
|
||||||
::unsafe::transmute(v)
|
::unsafe::transmute(move v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,7 +574,7 @@ impl TaskBuilder {
|
||||||
do fr_task_builder.spawn |move f| {
|
do fr_task_builder.spawn |move f| {
|
||||||
comm::send(ch, f());
|
comm::send(ch, f());
|
||||||
}
|
}
|
||||||
match future::get(&option::unwrap(result)) {
|
match future::get(&option::unwrap(move result)) {
|
||||||
Success => result::Ok(comm::recv(po)),
|
Success => result::Ok(comm::recv(po)),
|
||||||
Failure => result::Err(())
|
Failure => result::Err(())
|
||||||
}
|
}
|
||||||
|
@ -972,7 +972,7 @@ fn each_ancestor(list: &mut AncestorList,
|
||||||
if coalesce_this.is_some() {
|
if coalesce_this.is_some() {
|
||||||
// Needed coalesce. Our next ancestor becomes our old
|
// Needed coalesce. Our next ancestor becomes our old
|
||||||
// ancestor's next ancestor. ("next = old_next->next;")
|
// ancestor's next ancestor. ("next = old_next->next;")
|
||||||
*list <- option::unwrap(coalesce_this);
|
*list <- option::unwrap(move coalesce_this);
|
||||||
} else {
|
} else {
|
||||||
// No coalesce; restore from tmp. ("next = old_next;")
|
// No coalesce; restore from tmp. ("next = old_next;")
|
||||||
*list <- tmp_list;
|
*list <- tmp_list;
|
||||||
|
@ -1144,7 +1144,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
|
||||||
let newstate = util::replace(state, None);
|
let newstate = util::replace(state, None);
|
||||||
// If 'None', the group was failing. Can't enlist.
|
// If 'None', the group was failing. Can't enlist.
|
||||||
if newstate.is_some() {
|
if newstate.is_some() {
|
||||||
let group = option::unwrap(newstate);
|
let group = option::unwrap(move newstate);
|
||||||
taskset_insert(if is_member { &mut group.members }
|
taskset_insert(if is_member { &mut group.members }
|
||||||
else { &mut group.descendants }, me);
|
else { &mut group.descendants }, me);
|
||||||
*state = Some(move group);
|
*state = Some(move group);
|
||||||
|
@ -1159,7 +1159,7 @@ fn leave_taskgroup(state: TaskGroupInner, me: *rust_task, is_member: bool) {
|
||||||
let newstate = util::replace(state, None);
|
let newstate = util::replace(state, None);
|
||||||
// If 'None', already failing and we've already gotten a kill signal.
|
// If 'None', already failing and we've already gotten a kill signal.
|
||||||
if newstate.is_some() {
|
if newstate.is_some() {
|
||||||
let group = option::unwrap(newstate);
|
let group = option::unwrap(move newstate);
|
||||||
taskset_remove(if is_member { &mut group.members }
|
taskset_remove(if is_member { &mut group.members }
|
||||||
else { &mut group.descendants }, me);
|
else { &mut group.descendants }, me);
|
||||||
*state = Some(move group);
|
*state = Some(move group);
|
||||||
|
@ -1181,7 +1181,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
|
||||||
// That's ok; only one task needs to do the dirty work. (Might also
|
// That's ok; only one task needs to do the dirty work. (Might also
|
||||||
// see 'None' if Somebody already failed and we got a kill signal.)
|
// see 'None' if Somebody already failed and we got a kill signal.)
|
||||||
if newstate.is_some() {
|
if newstate.is_some() {
|
||||||
let group = option::unwrap(newstate);
|
let group = option::unwrap(move newstate);
|
||||||
for taskset_each(&group.members) |+sibling| {
|
for taskset_each(&group.members) |+sibling| {
|
||||||
// Skip self - killing ourself won't do much good.
|
// Skip self - killing ourself won't do much good.
|
||||||
if sibling != me {
|
if sibling != me {
|
||||||
|
@ -1277,7 +1277,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
|
||||||
// None { ancestor_list(None) }
|
// None { ancestor_list(None) }
|
||||||
let tmp = util::replace(&mut **ancestors, None);
|
let tmp = util::replace(&mut **ancestors, None);
|
||||||
if tmp.is_some() {
|
if tmp.is_some() {
|
||||||
let ancestor_arc = option::unwrap(tmp);
|
let ancestor_arc = option::unwrap(move tmp);
|
||||||
let result = ancestor_arc.clone();
|
let result = ancestor_arc.clone();
|
||||||
**ancestors <- Some(move ancestor_arc);
|
**ancestors <- Some(move ancestor_arc);
|
||||||
AncestorList(Some(move result))
|
AncestorList(Some(move result))
|
||||||
|
@ -1319,7 +1319,7 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
|
||||||
// closure. (Reordering them wouldn't help - then getting killed
|
// closure. (Reordering them wouldn't help - then getting killed
|
||||||
// between them would leak.)
|
// between them would leak.)
|
||||||
rustrt::start_task(new_task, closure);
|
rustrt::start_task(new_task, closure);
|
||||||
unsafe::forget(child_wrapper);
|
unsafe::forget(move child_wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1500,7 +1500,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
|
||||||
unsafe::bump_box_refcount(map);
|
unsafe::bump_box_refcount(map);
|
||||||
map
|
map
|
||||||
} else {
|
} else {
|
||||||
let map = unsafe::transmute(map_ptr);
|
let map = unsafe::transmute(move map_ptr);
|
||||||
unsafe::bump_box_refcount(map);
|
unsafe::bump_box_refcount(map);
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1546,7 @@ unsafe fn local_get_helper<T: Owned>(
|
||||||
// overwriting the local_data_box we need to give an extra reference.
|
// overwriting the local_data_box we need to give an extra reference.
|
||||||
// We must also give an extra reference when not removing.
|
// We must also give an extra reference when not removing.
|
||||||
let (index, data_ptr) = result;
|
let (index, data_ptr) = result;
|
||||||
let data: @T = unsafe::transmute(data_ptr);
|
let data: @T = unsafe::transmute(move data_ptr);
|
||||||
unsafe::bump_box_refcount(data);
|
unsafe::bump_box_refcount(data);
|
||||||
if do_pop {
|
if do_pop {
|
||||||
(*map).set_elt(index, None);
|
(*map).set_elt(index, None);
|
||||||
|
@ -1608,7 +1608,7 @@ unsafe fn local_modify<T: Owned>(
|
||||||
// Could be more efficient by doing the lookup work, but this is easy.
|
// Could be more efficient by doing the lookup work, but this is easy.
|
||||||
let newdata = modify_fn(local_pop(task, key));
|
let newdata = modify_fn(local_pop(task, key));
|
||||||
if newdata.is_some() {
|
if newdata.is_some() {
|
||||||
local_set(task, key, option::unwrap(newdata));
|
local_set(task, key, option::unwrap(move newdata));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,15 @@ unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
|
||||||
* reinterpret_cast on managed pointer types.
|
* reinterpret_cast on managed pointer types.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn forget<T>(-thing: T) { rusti::forget(thing); }
|
unsafe fn forget<T>(-thing: T) { rusti::forget(move thing); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force-increment the reference count on a shared box. If used
|
* Force-increment the reference count on a shared box. If used
|
||||||
* uncarefully, this can leak the box. Use this in conjunction with transmute
|
* carelessly, this can leak the box. Use this in conjunction with transmute
|
||||||
* and/or reinterpret_cast when such calls would otherwise scramble a box's
|
* and/or reinterpret_cast when such calls would otherwise scramble a box's
|
||||||
* reference count
|
* reference count
|
||||||
*/
|
*/
|
||||||
unsafe fn bump_box_refcount<T>(+t: @T) { forget(t); }
|
unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform a value of one type into a value of another type.
|
* Transform a value of one type into a value of another type.
|
||||||
|
@ -51,23 +51,26 @@ unsafe fn bump_box_refcount<T>(+t: @T) { forget(t); }
|
||||||
* assert transmute("L") == ~[76u8, 0u8];
|
* assert transmute("L") == ~[76u8, 0u8];
|
||||||
*/
|
*/
|
||||||
unsafe fn transmute<L, G>(-thing: L) -> G {
|
unsafe fn transmute<L, G>(-thing: L) -> G {
|
||||||
let newthing = reinterpret_cast(&thing);
|
debug!(">>> in transmute! <<<");
|
||||||
forget(thing);
|
debug!("transmute 1: %?", &thing);
|
||||||
|
let newthing: G = reinterpret_cast(&thing);
|
||||||
|
forget(move thing);
|
||||||
|
debug!("transmute 2: %?", &newthing);
|
||||||
move newthing
|
move newthing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Coerce an immutable reference to be mutable.
|
/// Coerce an immutable reference to be mutable.
|
||||||
unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(ptr) }
|
unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) }
|
||||||
|
|
||||||
/// Coerce a mutable reference to be immutable.
|
/// Coerce a mutable reference to be immutable.
|
||||||
unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T { transmute(ptr) }
|
unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T { transmute(move ptr) }
|
||||||
|
|
||||||
/// Coerce a borrowed pointer to have an arbitrary associated region.
|
/// Coerce a borrowed pointer to have an arbitrary associated region.
|
||||||
unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(ptr) }
|
unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(move ptr) }
|
||||||
|
|
||||||
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
|
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
|
||||||
unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T {
|
unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T {
|
||||||
transmute(ptr)
|
transmute(move ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transforms lifetime of the second pointer to match the first.
|
/// Transforms lifetime of the second pointer to match the first.
|
||||||
|
@ -117,7 +120,7 @@ struct ArcDestruct<T> {
|
||||||
// Unkillable wait. Message guaranteed to come.
|
// Unkillable wait. Message guaranteed to come.
|
||||||
if pipes::recv_one(move response) {
|
if pipes::recv_one(move response) {
|
||||||
// Other task got the data.
|
// Other task got the data.
|
||||||
unsafe::forget(data);
|
unsafe::forget(move data);
|
||||||
} else {
|
} else {
|
||||||
// Other task was killed. drop glue takes over.
|
// Other task was killed. drop glue takes over.
|
||||||
}
|
}
|
||||||
|
@ -125,7 +128,7 @@ struct ArcDestruct<T> {
|
||||||
// drop glue takes over.
|
// drop glue takes over.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsafe::forget(data);
|
unsafe::forget(move data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +166,7 @@ unsafe fn unwrap_shared_mutable_state<T: Send>(+rc: SharedMutableState<T>)
|
||||||
let (c1,p1) = pipes::oneshot(); // ()
|
let (c1,p1) = pipes::oneshot(); // ()
|
||||||
let (c2,p2) = pipes::oneshot(); // bool
|
let (c2,p2) = pipes::oneshot(); // bool
|
||||||
let server: UnwrapProto = ~mut Some((move c1,move p2));
|
let server: UnwrapProto = ~mut Some((move c1,move p2));
|
||||||
let serverp: libc::uintptr_t = unsafe::transmute(server);
|
let serverp: libc::uintptr_t = unsafe::transmute(move server);
|
||||||
// Try to put our server end in the unwrapper slot.
|
// Try to put our server end in the unwrapper slot.
|
||||||
if rustrt::rust_compare_and_swap_ptr(&mut ptr.unwrapper, 0, serverp) {
|
if rustrt::rust_compare_and_swap_ptr(&mut ptr.unwrapper, 0, serverp) {
|
||||||
// Got in. Step 0: Tell destructor not to run. We are now it.
|
// Got in. Step 0: Tell destructor not to run. We are now it.
|
||||||
|
@ -174,7 +177,7 @@ unsafe fn unwrap_shared_mutable_state<T: Send>(+rc: SharedMutableState<T>)
|
||||||
if new_count == 0 {
|
if new_count == 0 {
|
||||||
// We were the last owner. Can unwrap immediately.
|
// We were the last owner. Can unwrap immediately.
|
||||||
// Also we have to free the server endpoints.
|
// Also we have to free the server endpoints.
|
||||||
let _server: UnwrapProto = unsafe::transmute(serverp);
|
let _server: UnwrapProto = unsafe::transmute(move serverp);
|
||||||
option::swap_unwrap(&mut ptr.data)
|
option::swap_unwrap(&mut ptr.data)
|
||||||
// drop glue takes over.
|
// drop glue takes over.
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,9 +197,9 @@ unsafe fn unwrap_shared_mutable_state<T: Send>(+rc: SharedMutableState<T>)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Somebody else was trying to unwrap. Avoid guaranteed deadlock.
|
// Somebody else was trying to unwrap. Avoid guaranteed deadlock.
|
||||||
unsafe::forget(ptr);
|
unsafe::forget(move ptr);
|
||||||
// Also we have to free the (rejected) server endpoints.
|
// Also we have to free the (rejected) server endpoints.
|
||||||
let _server: UnwrapProto = unsafe::transmute(serverp);
|
let _server: UnwrapProto = unsafe::transmute(move serverp);
|
||||||
fail ~"Another task is already unwrapping this ARC!";
|
fail ~"Another task is already unwrapping this ARC!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +216,7 @@ type SharedMutableState<T: Send> = ArcDestruct<T>;
|
||||||
unsafe fn shared_mutable_state<T: Send>(+data: T) -> SharedMutableState<T> {
|
unsafe fn shared_mutable_state<T: Send>(+data: T) -> SharedMutableState<T> {
|
||||||
let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) };
|
let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) };
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = unsafe::transmute(data);
|
let ptr = unsafe::transmute(move data);
|
||||||
ArcDestruct(ptr)
|
ArcDestruct(ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +229,7 @@ unsafe fn get_shared_mutable_state<T: Send>(rc: &a/SharedMutableState<T>)
|
||||||
assert ptr.count > 0;
|
assert ptr.count > 0;
|
||||||
// Cast us back into the correct region
|
// Cast us back into the correct region
|
||||||
let r = unsafe::transmute_region(option::get_ref(&ptr.data));
|
let r = unsafe::transmute_region(option::get_ref(&ptr.data));
|
||||||
unsafe::forget(ptr);
|
unsafe::forget(move ptr);
|
||||||
return unsafe::transmute_mut(r);
|
return unsafe::transmute_mut(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +241,7 @@ unsafe fn get_shared_immutable_state<T: Send>(rc: &a/SharedMutableState<T>)
|
||||||
assert ptr.count > 0;
|
assert ptr.count > 0;
|
||||||
// Cast us back into the correct region
|
// Cast us back into the correct region
|
||||||
let r = unsafe::transmute_region(option::get_ref(&ptr.data));
|
let r = unsafe::transmute_region(option::get_ref(&ptr.data));
|
||||||
unsafe::forget(ptr);
|
unsafe::forget(move ptr);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +252,7 @@ unsafe fn clone_shared_mutable_state<T: Send>(rc: &SharedMutableState<T>)
|
||||||
let ptr: ~ArcData<T> = unsafe::reinterpret_cast(&(*rc).data);
|
let ptr: ~ArcData<T> = unsafe::reinterpret_cast(&(*rc).data);
|
||||||
let new_count = rustrt::rust_atomic_increment(&mut ptr.count);
|
let new_count = rustrt::rust_atomic_increment(&mut ptr.count);
|
||||||
assert new_count >= 2;
|
assert new_count >= 2;
|
||||||
unsafe::forget(ptr);
|
unsafe::forget(move ptr);
|
||||||
}
|
}
|
||||||
ArcDestruct((*rc).data)
|
ArcDestruct((*rc).data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,12 +271,12 @@ pure fn build_sized_opt<A>(size: Option<uint>,
|
||||||
|
|
||||||
/// Produces a mut vector from an immutable vector.
|
/// Produces a mut vector from an immutable vector.
|
||||||
pure fn to_mut<T>(+v: ~[T]) -> ~[mut T] {
|
pure fn to_mut<T>(+v: ~[T]) -> ~[mut T] {
|
||||||
unsafe { ::unsafe::transmute(v) }
|
unsafe { ::unsafe::transmute(move v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Produces an immutable vector from a mut vector.
|
/// Produces an immutable vector from a mut vector.
|
||||||
pure fn from_mut<T>(+v: ~[mut T]) -> ~[T] {
|
pure fn from_mut<T>(+v: ~[mut T]) -> ~[T] {
|
||||||
unsafe { ::unsafe::transmute(v) }
|
unsafe { ::unsafe::transmute(move v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
@ -580,7 +580,7 @@ unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
|
||||||
(**repr).fill += sys::size_of::<T>();
|
(**repr).fill += sys::size_of::<T>();
|
||||||
let p = ptr::addr_of((**repr).data);
|
let p = ptr::addr_of((**repr).data);
|
||||||
let p = ptr::offset(p, fill) as *mut T;
|
let p = ptr::offset(p, fill) as *mut T;
|
||||||
rusti::move_val_init(*p, initval);
|
rusti::move_val_init(*p, move initval);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
|
@ -1835,7 +1835,7 @@ mod unsafe {
|
||||||
let mut box2 = None;
|
let mut box2 = None;
|
||||||
box2 <-> box;
|
box2 <-> box;
|
||||||
rusti::move_val_init(*ptr::mut_offset(p, i),
|
rusti::move_val_init(*ptr::mut_offset(p, i),
|
||||||
option::unwrap(box2));
|
option::unwrap(move box2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ fn Bitv (nbits: uint, init: bool) -> Bitv {
|
||||||
if nbits % uint_bits == 0 {0} else {1};
|
if nbits % uint_bits == 0 {0} else {1};
|
||||||
let elem = if init {!0} else {0};
|
let elem = if init {!0} else {0};
|
||||||
let s = to_mut(from_elem(nelems, elem));
|
let s = to_mut(from_elem(nelems, elem));
|
||||||
Big(~BigBitv(s))
|
Big(~BigBitv(move s))
|
||||||
};
|
};
|
||||||
Bitv {rep: rep, nbits: nbits}
|
Bitv {rep: rep, nbits: nbits}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl<T> Cell<T> {
|
||||||
|
|
||||||
let mut value = None;
|
let mut value = None;
|
||||||
value <-> self.value;
|
value <-> self.value;
|
||||||
return option::unwrap(value);
|
return option::unwrap(move value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value, failing if the cell is full.
|
/// Returns the value, failing if the cell is full.
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn create<T: Copy>() -> Deque<T> {
|
||||||
self.lo = self.elts.len() - 1u;
|
self.lo = self.elts.len() - 1u;
|
||||||
} else { self.lo -= 1u; }
|
} else { self.lo -= 1u; }
|
||||||
if self.lo == self.hi {
|
if self.lo == self.hi {
|
||||||
self.elts.swap(|v| grow(self.nelts, oldlo, v));
|
self.elts.swap(|v| grow(self.nelts, oldlo, move v));
|
||||||
self.lo = self.elts.len() - 1u;
|
self.lo = self.elts.len() - 1u;
|
||||||
self.hi = self.nelts;
|
self.hi = self.nelts;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ fn create<T: Copy>() -> Deque<T> {
|
||||||
}
|
}
|
||||||
fn add_back(t: T) {
|
fn add_back(t: T) {
|
||||||
if self.lo == self.hi && self.nelts != 0u {
|
if self.lo == self.hi && self.nelts != 0u {
|
||||||
self.elts.swap(|v| grow(self.nelts, self.lo, v));
|
self.elts.swap(|v| grow(self.nelts, self.lo, move v));
|
||||||
self.lo = 0u;
|
self.lo = 0u;
|
||||||
self.hi = self.nelts;
|
self.hi = self.nelts;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ fn create<T: Copy>() -> Deque<T> {
|
||||||
vec::to_mut(
|
vec::to_mut(
|
||||||
vec::from_elem(initial_capacity, None)))
|
vec::from_elem(initial_capacity, None)))
|
||||||
};
|
};
|
||||||
move (repr as Deque::<T>)
|
(move repr) as Deque::<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -279,7 +279,7 @@ mod chained {
|
||||||
if opt_v.is_none() {
|
if opt_v.is_none() {
|
||||||
fail fmt!("Key not found in table: %?", k);
|
fail fmt!("Key not found in table: %?", k);
|
||||||
}
|
}
|
||||||
option::unwrap(opt_v)
|
option::unwrap(move opt_v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove(+k: K) -> bool {
|
fn remove(+k: K) -> bool {
|
||||||
|
|
|
@ -275,7 +275,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
|
||||||
result::Err(GetAddrUnknownError));
|
result::Err(GetAddrUnknownError));
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
out_vec += ~[new_ip_addr];
|
out_vec += ~[move new_ip_addr];
|
||||||
|
|
||||||
let next_addr = ll::get_next_addrinfo(curr_addr);
|
let next_addr = ll::get_next_addrinfo(curr_addr);
|
||||||
if next_addr == ptr::null::<addrinfo>() as *addrinfo {
|
if next_addr == ptr::null::<addrinfo>() as *addrinfo {
|
||||||
|
@ -289,7 +289,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
|
||||||
}
|
}
|
||||||
log(debug, fmt!("successful process addrinfo result, len: %?",
|
log(debug, fmt!("successful process addrinfo result, len: %?",
|
||||||
vec::len(out_vec)));
|
vec::len(out_vec)));
|
||||||
(*handle_data).output_ch.send(result::Ok(out_vec));
|
(*handle_data).output_ch.send(result::Ok(move out_vec));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log(debug, ~"addrinfo pointer is NULL");
|
log(debug, ~"addrinfo pointer is NULL");
|
||||||
|
|
|
@ -155,7 +155,7 @@ fn connect(-input_ip: ip::IpAddr, port: uint,
|
||||||
// we can send into the interact cb to be handled in libuv..
|
// we can send into the interact cb to be handled in libuv..
|
||||||
log(debug, fmt!("stream_handle_ptr outside interact %?",
|
log(debug, fmt!("stream_handle_ptr outside interact %?",
|
||||||
stream_handle_ptr));
|
stream_handle_ptr));
|
||||||
do iotask::interact(iotask) |loop_ptr| unsafe {
|
do iotask::interact(iotask) |move input_ip, loop_ptr| unsafe {
|
||||||
log(debug, ~"in interact cb for tcp client connect..");
|
log(debug, ~"in interact cb for tcp client connect..");
|
||||||
log(debug, fmt!("stream_handle_ptr in interact %?",
|
log(debug, fmt!("stream_handle_ptr in interact %?",
|
||||||
stream_handle_ptr));
|
stream_handle_ptr));
|
||||||
|
@ -575,7 +575,7 @@ fn listen(-host_ip: ip::IpAddr, port: uint, backlog: uint,
|
||||||
+new_connect_cb: fn~(TcpNewConnection,
|
+new_connect_cb: fn~(TcpNewConnection,
|
||||||
comm::Chan<Option<TcpErrData>>))
|
comm::Chan<Option<TcpErrData>>))
|
||||||
-> result::Result<(), TcpListenErrData> unsafe {
|
-> result::Result<(), TcpListenErrData> unsafe {
|
||||||
do listen_common(host_ip, port, backlog, iotask, on_establish_cb)
|
do listen_common(move host_ip, port, backlog, iotask, on_establish_cb)
|
||||||
// on_connect_cb
|
// on_connect_cb
|
||||||
|move new_connect_cb, handle| unsafe {
|
|move new_connect_cb, handle| unsafe {
|
||||||
let server_data_ptr = uv::ll::get_data_for_uv_handle(handle)
|
let server_data_ptr = uv::ll::get_data_for_uv_handle(handle)
|
||||||
|
@ -600,7 +600,7 @@ fn listen_common(-host_ip: ip::IpAddr, port: uint, backlog: uint,
|
||||||
server_stream_ptr: server_stream_ptr,
|
server_stream_ptr: server_stream_ptr,
|
||||||
stream_closed_ch: core::comm::Chan(stream_closed_po),
|
stream_closed_ch: core::comm::Chan(stream_closed_po),
|
||||||
kill_ch: kill_ch,
|
kill_ch: kill_ch,
|
||||||
on_connect_cb: on_connect_cb,
|
on_connect_cb: move on_connect_cb,
|
||||||
iotask: iotask,
|
iotask: iotask,
|
||||||
mut active: true
|
mut active: true
|
||||||
};
|
};
|
||||||
|
@ -614,7 +614,7 @@ fn listen_common(-host_ip: ip::IpAddr, port: uint, backlog: uint,
|
||||||
// tcp::connect (because the iotask::interact cb isn't
|
// tcp::connect (because the iotask::interact cb isn't
|
||||||
// nested within a core::comm::listen block)
|
// nested within a core::comm::listen block)
|
||||||
let loc_ip = copy(host_ip);
|
let loc_ip = copy(host_ip);
|
||||||
do iotask::interact(iotask) |loop_ptr| unsafe {
|
do iotask::interact(iotask) |move loc_ip, loop_ptr| unsafe {
|
||||||
match uv::ll::tcp_init(loop_ptr, server_stream_ptr) {
|
match uv::ll::tcp_init(loop_ptr, server_stream_ptr) {
|
||||||
0i32 => {
|
0i32 => {
|
||||||
uv::ll::set_data_for_uv_handle(
|
uv::ll::set_data_for_uv_handle(
|
||||||
|
@ -739,7 +739,7 @@ impl TcpSocket {
|
||||||
fn read_stop(-read_port:
|
fn read_stop(-read_port:
|
||||||
comm::Port<result::Result<~[u8], TcpErrData>>) ->
|
comm::Port<result::Result<~[u8], TcpErrData>>) ->
|
||||||
result::Result<(), TcpErrData> {
|
result::Result<(), TcpErrData> {
|
||||||
read_stop(self, read_port)
|
read_stop(self, move read_port)
|
||||||
}
|
}
|
||||||
fn read(timeout_msecs: uint) ->
|
fn read(timeout_msecs: uint) ->
|
||||||
result::Result<~[u8], TcpErrData> {
|
result::Result<~[u8], TcpErrData> {
|
||||||
|
@ -1491,7 +1491,8 @@ mod test {
|
||||||
cont_ch: comm::Chan<()>,
|
cont_ch: comm::Chan<()>,
|
||||||
iotask: IoTask) -> ~str {
|
iotask: IoTask) -> ~str {
|
||||||
let server_ip_addr = ip::v4::parse_addr(server_ip);
|
let server_ip_addr = ip::v4::parse_addr(server_ip);
|
||||||
let listen_result = listen(server_ip_addr, server_port, 128u, iotask,
|
let listen_result = listen(move server_ip_addr, server_port, 128,
|
||||||
|
iotask,
|
||||||
// on_establish_cb -- called when listener is set up
|
// on_establish_cb -- called when listener is set up
|
||||||
|kill_ch| {
|
|kill_ch| {
|
||||||
log(debug, fmt!("establish_cb %?",
|
log(debug, fmt!("establish_cb %?",
|
||||||
|
@ -1574,7 +1575,8 @@ mod test {
|
||||||
fn run_tcp_test_server_fail(server_ip: ~str, server_port: uint,
|
fn run_tcp_test_server_fail(server_ip: ~str, server_port: uint,
|
||||||
iotask: IoTask) -> TcpListenErrData {
|
iotask: IoTask) -> TcpListenErrData {
|
||||||
let server_ip_addr = ip::v4::parse_addr(server_ip);
|
let server_ip_addr = ip::v4::parse_addr(server_ip);
|
||||||
let listen_result = listen(server_ip_addr, server_port, 128u, iotask,
|
let listen_result = listen(move server_ip_addr, server_port, 128,
|
||||||
|
iotask,
|
||||||
// on_establish_cb -- called when listener is set up
|
// on_establish_cb -- called when listener is set up
|
||||||
|kill_ch| {
|
|kill_ch| {
|
||||||
log(debug, fmt!("establish_cb %?",
|
log(debug, fmt!("establish_cb %?",
|
||||||
|
@ -1600,7 +1602,8 @@ mod test {
|
||||||
let server_ip_addr = ip::v4::parse_addr(server_ip);
|
let server_ip_addr = ip::v4::parse_addr(server_ip);
|
||||||
|
|
||||||
log(debug, ~"CLIENT: starting..");
|
log(debug, ~"CLIENT: starting..");
|
||||||
let connect_result = connect(server_ip_addr, server_port, iotask);
|
let connect_result = connect(move server_ip_addr, server_port,
|
||||||
|
iotask);
|
||||||
if result::is_err(connect_result) {
|
if result::is_err(connect_result) {
|
||||||
log(debug, ~"CLIENT: failed to connect");
|
log(debug, ~"CLIENT: failed to connect");
|
||||||
let err_data = result::get_err(connect_result);
|
let err_data = result::get_err(connect_result);
|
||||||
|
|
|
@ -814,11 +814,11 @@ mod node {
|
||||||
offset += 1u;
|
offset += 1u;
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
unsafe::forget(local_buf);
|
unsafe::forget(move local_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return unsafe::transmute(buf);
|
return unsafe::transmute(move buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -253,7 +253,7 @@ fn sha1() -> Sha1 {
|
||||||
mut computed: false,
|
mut computed: false,
|
||||||
work_buf: @vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
work_buf: @vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
||||||
};
|
};
|
||||||
let sh <- st as Sha1;
|
let sh = (move st) as Sha1;
|
||||||
sh.reset();
|
sh.reset();
|
||||||
return sh;
|
return sh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl<Q: Send> &Sem<Q> {
|
||||||
/* for 1000.times { task::yield(); } */
|
/* for 1000.times { task::yield(); } */
|
||||||
// Need to wait outside the exclusive.
|
// Need to wait outside the exclusive.
|
||||||
if waiter_nobe.is_some() {
|
if waiter_nobe.is_some() {
|
||||||
let _ = pipes::recv_one(option::unwrap(waiter_nobe));
|
let _ = pipes::recv_one(option::unwrap(move waiter_nobe));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn release() {
|
fn release() {
|
||||||
|
|
|
@ -401,7 +401,7 @@ fn run_test(+test: TestDesc, monitor_ch: comm::Chan<MonitorMsg>) {
|
||||||
task::task().unlinked().future_result(|+r| {
|
task::task().unlinked().future_result(|+r| {
|
||||||
result_future = Some(move r);
|
result_future = Some(move r);
|
||||||
}).spawn(move testfn);
|
}).spawn(move testfn);
|
||||||
let task_result = future::get(&option::unwrap(result_future));
|
let task_result = future::get(&option::unwrap(move result_future));
|
||||||
let test_result = calc_result(test, task_result == task::Success);
|
let test_result = calc_result(test, task_result == task::Success);
|
||||||
comm::send(monitor_ch, (copy test, test_result));
|
comm::send(monitor_ch, (copy test, test_result));
|
||||||
};
|
};
|
||||||
|
|
|
@ -104,7 +104,7 @@ fn spawn_loop() -> IoTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
spawn_iotask(builder)
|
spawn_iotask(move builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue