diff options
Diffstat (limited to 'src/libcore/private.rs')
| -rw-r--r-- | src/libcore/private.rs | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 9df31bbd81f..5b69c348c15 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -145,11 +145,11 @@ struct ArcDestruct<T> { cast::reinterpret_cast(&data.unwrapper); let (message, response) = option::swap_unwrap(p); // Send 'ready' and wait for a response. - pipes::send_one(move message, ()); + pipes::send_one(message, ()); // Unkillable wait. Message guaranteed to come. - if pipes::recv_one(move response) { + if pipes::recv_one(response) { // Other task got the data. - cast::forget(move data); + cast::forget(data); } else { // Other task was killed. drop glue takes over. } @@ -157,7 +157,7 @@ struct ArcDestruct<T> { // drop glue takes over. } } else { - cast::forget(move data); + cast::forget(data); } } } @@ -182,13 +182,13 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) // tried to wake us whether they should hand-off the data to // us. if task::failing() { - pipes::send_one(move response, false); + pipes::send_one(response, false); // Either this swap_unwrap or the one below (at "Got // here") ought to run. cast::forget(option::swap_unwrap(&mut self.ptr)); } else { assert self.ptr.is_none(); - pipes::send_one(move response, true); + pipes::send_one(response, true); } } } @@ -198,8 +198,8 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) let ptr: ~ArcData<T> = cast::reinterpret_cast(&rc.data); let (p1,c1) = pipes::oneshot(); // () let (p2,c2) = pipes::oneshot(); // bool - let server: UnwrapProto = ~mut Some((move c1,move p2)); - let serverp: int = cast::transmute(move server); + let server: UnwrapProto = ~mut Some((c1,p2)); + let serverp: int = cast::transmute(server); // Try to put our server end in the unwrapper slot. if compare_and_swap(&mut ptr.unwrapper, 0, serverp) { // Got in. Step 0: Tell destructor not to run. We are now it. @@ -210,15 +210,15 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) if new_count == 0 { // We were the last owner. Can unwrap immediately. // Also we have to free the server endpoints. - let _server: UnwrapProto = cast::transmute(move serverp); + let _server: UnwrapProto = cast::transmute(serverp); option::swap_unwrap(&mut ptr.data) // drop glue takes over. } else { // The *next* person who sees the refcount hit 0 will wake us. let end_result = - DeathThroes { ptr: Some(move ptr), - response: Some(move c2) }; - let mut p1 = Some(move p1); // argh + DeathThroes { ptr: Some(ptr), + response: Some(c2) }; + let mut p1 = Some(p1); // argh do task::rekillable { pipes::recv_one(option::swap_unwrap(&mut p1)); } @@ -230,9 +230,9 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) } } else { // Somebody else was trying to unwrap. Avoid guaranteed deadlock. - cast::forget(move ptr); + cast::forget(ptr); // Also we have to free the (rejected) server endpoints. - let _server: UnwrapProto = cast::transmute(move serverp); + let _server: UnwrapProto = cast::transmute(serverp); fail!(~"Another task is already unwrapping this ARC!"); } } @@ -248,9 +248,9 @@ pub type SharedMutableState<T> = ArcDestruct<T>; pub unsafe fn shared_mutable_state<T: Owned>(data: T) -> SharedMutableState<T> { - let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) }; + let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) }; unsafe { - let ptr = cast::transmute(move data); + let ptr = cast::transmute(data); ArcDestruct(ptr) } } @@ -263,7 +263,7 @@ pub unsafe fn get_shared_mutable_state<T: Owned>( let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data); assert ptr.count > 0; let r = cast::transmute(option::get_ref(&ptr.data)); - cast::forget(move ptr); + cast::forget(ptr); return r; } } @@ -275,7 +275,7 @@ pub unsafe fn get_shared_immutable_state<T: Owned>( assert ptr.count > 0; // Cast us back into the correct region let r = cast::transmute_region(option::get_ref(&ptr.data)); - cast::forget(move ptr); + cast::forget(ptr); return r; } } @@ -286,7 +286,7 @@ pub unsafe fn clone_shared_mutable_state<T: Owned>(rc: &SharedMutableState<T>) let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data); let new_count = rusti::atomic_xadd(&mut ptr.count, 1) + 1; assert new_count >= 2; - cast::forget(move ptr); + cast::forget(ptr); } ArcDestruct((*rc).data) } @@ -355,9 +355,9 @@ pub struct Exclusive<T> { x: SharedMutableState<ExData<T>> } pub fn exclusive<T:Owned >(user_data: T) -> Exclusive<T> { let data = ExData { - lock: LittleLock(), mut failed: false, mut data: move user_data + lock: LittleLock(), mut failed: false, mut data: user_data }; - Exclusive { x: unsafe { shared_mutable_state(move data) } } + Exclusive { x: unsafe { shared_mutable_state(data) } } } impl<T: Owned> Clone for Exclusive<T> { @@ -386,7 +386,7 @@ impl<T: Owned> Exclusive<T> { (*rec).failed = true; let result = f(&mut (*rec).data); (*rec).failed = false; - move result + result } } } @@ -401,10 +401,10 @@ impl<T: Owned> Exclusive<T> { // FIXME(#3724) make this a by-move method on the exclusive 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; - move data + let Exclusive { x: x } = arc; + let inner = unsafe { unwrap_shared_mutable_state(x) }; + let ExData { data: data, _ } = inner; + data } #[cfg(test)] @@ -430,9 +430,9 @@ pub mod tests { for uint::range(0, num_tasks) |_i| { let total = total.clone(); let (port, chan) = pipes::stream(); - futures.push(move port); + futures.push(port); - do task::spawn |move total, move chan| { + do task::spawn || { for uint::range(0, count) |_i| { do total.with |count| { **count += 1; @@ -455,7 +455,7 @@ pub mod tests { // accesses will also fail. let x = exclusive(1); let x2 = x.clone(); - do task::try |move x2| { + do task::try || { do x2.with |one| { assert *one == 2; } @@ -468,31 +468,31 @@ pub mod tests { #[test] pub fn exclusive_unwrap_basic() { let x = exclusive(~~"hello"); - assert unwrap_exclusive(move x) == ~~"hello"; + assert unwrap_exclusive(x) == ~~"hello"; } #[test] pub fn exclusive_unwrap_contended() { let x = exclusive(~~"hello"); let x2 = ~mut Some(x.clone()); - do task::spawn |move x2| { + do task::spawn || { let x2 = option::swap_unwrap(x2); do x2.with |_hello| { } task::yield(); } - assert unwrap_exclusive(move x) == ~~"hello"; + assert unwrap_exclusive(x) == ~~"hello"; // Now try the same thing, but with the child task blocking. let x = exclusive(~~"hello"); let x2 = ~mut Some(x.clone()); let mut res = None; - do task::task().future_result(|+r| res = Some(move r)).spawn - |move x2| { + do task::task().future_result(|+r| res = Some(r)).spawn + || { let x2 = option::swap_unwrap(x2); - assert unwrap_exclusive(move x2) == ~~"hello"; + assert unwrap_exclusive(x2) == ~~"hello"; } // Have to get rid of our reference before blocking. - { let _x = move x; } // FIXME(#3161) util::ignore doesn't work here + { let _x = x; } // FIXME(#3161) util::ignore doesn't work here let res = option::swap_unwrap(&mut res); res.recv(); } @@ -502,12 +502,12 @@ pub mod tests { let x = exclusive(~~"hello"); let x2 = ~mut Some(x.clone()); let mut res = None; - do task::task().future_result(|+r| res = Some(move r)).spawn - |move x2| { + do task::task().future_result(|+r| res = Some(r)).spawn + || { let x2 = option::swap_unwrap(x2); - assert unwrap_exclusive(move x2) == ~~"hello"; + assert unwrap_exclusive(x2) == ~~"hello"; } - assert unwrap_exclusive(move x) == ~~"hello"; + assert unwrap_exclusive(x) == ~~"hello"; let res = option::swap_unwrap(&mut res); res.recv(); } @@ -526,7 +526,7 @@ pub mod tests { for 10.times { task::yield(); } // try to let the unwrapper go fail!(); // punt it awake from its deadlock } - let _z = unwrap_exclusive(move x); + let _z = unwrap_exclusive(x); do x2.with |_hello| { } }; assert result.is_err(); |
