Remove moves from *T and implement in another way
This commit is contained in:
parent
eb48c29681
commit
e7b0b71197
@ -122,7 +122,7 @@ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn())
|
||||
*/
|
||||
pub fn get<T:Copy>(t: CVec<T>, ofs: uint) -> T {
|
||||
assert!(ofs < len(t));
|
||||
return unsafe { *ptr::mut_offset(t.base, ofs) };
|
||||
return unsafe { copy *ptr::mut_offset(t.base, ofs) };
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,8 @@ bounded and unbounded protocols allows for less code duplication.
|
||||
#[allow(missing_doc)];
|
||||
|
||||
use container::Container;
|
||||
use cast::{forget, transmute, transmute_copy};
|
||||
use cast::{forget, transmute, transmute_copy, transmute_mut};
|
||||
use cast;
|
||||
use either::{Either, Left, Right};
|
||||
use iterator::IteratorUtil;
|
||||
use kinds::Owned;
|
||||
@ -102,10 +103,6 @@ use util::replace;
|
||||
|
||||
static SPIN_COUNT: uint = 0;
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => ( unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } )
|
||||
)
|
||||
|
||||
#[deriving(Eq)]
|
||||
enum State {
|
||||
Empty,
|
||||
@ -316,9 +313,11 @@ impl<T> Drop for BufferResource<T> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
// FIXME(#4330) Need self by value to get mutability.
|
||||
let this: &mut BufferResource<T> = transmute(self);
|
||||
let this: &mut BufferResource<T> = transmute_mut(self);
|
||||
|
||||
let null_buffer: ~Buffer<T> = transmute(ptr::null::<Buffer<T>>());
|
||||
let mut b = replace(&mut this.buffer, null_buffer);
|
||||
|
||||
let mut b = move_it!(this.buffer);
|
||||
//let p = ptr::to_unsafe_ptr(*b);
|
||||
//error!("drop %?", p);
|
||||
let old_count = intrinsics::atomic_xsub_rel(
|
||||
|
@ -98,10 +98,6 @@ use iterator::{IteratorUtil};
|
||||
#[cfg(test)] use comm;
|
||||
#[cfg(test)] use task;
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => ( unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } )
|
||||
)
|
||||
|
||||
type TaskSet = HashSet<*rust_task>;
|
||||
|
||||
fn new_taskset() -> TaskSet {
|
||||
@ -638,23 +634,16 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
|
||||
notify_chan: Option<Chan<TaskResult>>,
|
||||
f: ~fn())
|
||||
-> ~fn() {
|
||||
let child_data = Cell::new((child_arc, ancestors));
|
||||
let child_data = Cell::new((notify_chan, child_arc, ancestors));
|
||||
let result: ~fn() = || {
|
||||
// Agh. Get move-mode items into the closure. FIXME (#2829)
|
||||
let mut (child_arc, ancestors) = child_data.take();
|
||||
let mut (notify_chan, child_arc, ancestors) = child_data.take();
|
||||
// Child task runs this code.
|
||||
|
||||
// Even if the below code fails to kick the child off, we must
|
||||
// send Something on the notify channel.
|
||||
|
||||
//let mut notifier = None;//notify_chan.map(|c| AutoNotify(c));
|
||||
let notifier = match notify_chan {
|
||||
Some(ref notify_chan_value) => {
|
||||
let moved_ncv = move_it!(*notify_chan_value);
|
||||
Some(AutoNotify(moved_ncv))
|
||||
}
|
||||
_ => None
|
||||
};
|
||||
let notifier = notify_chan.map_consume(|c| AutoNotify(c));
|
||||
|
||||
if enlist_many(child, &child_arc, &mut ancestors) {
|
||||
let group = @@mut TCB(child,
|
||||
|
@ -45,24 +45,18 @@ proto! bank (
|
||||
}
|
||||
)
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||
)
|
||||
|
||||
fn switch<T:Owned,U>(endp: pipes::RecvPacket<T>,
|
||||
f: &fn(v: Option<T>) -> U) -> U {
|
||||
f(pipes::try_recv(endp))
|
||||
}
|
||||
|
||||
fn move_it<T>(x: T) -> T { x }
|
||||
|
||||
macro_rules! follow (
|
||||
{
|
||||
$($message:path$(($($x: ident),+))||* -> $next:ident $e:expr)+
|
||||
} => (
|
||||
|m| match m {
|
||||
$(Some($message($($($x,)+)* next)) => {
|
||||
let $next = move_it!(next);
|
||||
let $next = next;
|
||||
$e })+
|
||||
_ => { fail!() }
|
||||
}
|
||||
@ -96,7 +90,7 @@ fn bank_client(bank: bank::client::login) {
|
||||
let bank = client::login(bank, ~"theincredibleholk", ~"1234");
|
||||
let bank = match try_recv(bank) {
|
||||
Some(ok(connected)) => {
|
||||
move_it!(connected)
|
||||
connected
|
||||
}
|
||||
Some(invalid(_)) => { fail!("login unsuccessful") }
|
||||
None => { fail!("bank closed the connection") }
|
||||
|
Loading…
Reference in New Issue
Block a user