mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Make moves explicit in rpass tests
This commit is contained in:
parent
2145348090
commit
3ebd878f4a
@ -12,7 +12,7 @@ fn f2(a: int, f: fn(int)) -> int { f(1); return a; }
|
||||
|
||||
fn main() {
|
||||
let mut a = {mut x: 1}, b = 2, c = 3;
|
||||
assert (f1(a, &mut b, c) == 6);
|
||||
assert (f1(a, &mut b, move c) == 6);
|
||||
assert (a.x == 0);
|
||||
assert (b == 10);
|
||||
assert (f2(a.x, |x| a.x = 50 ) == 0);
|
||||
|
@ -4,7 +4,7 @@ trait Pushable<T> {
|
||||
|
||||
impl<T> ~[T]: Pushable<T> {
|
||||
fn push_val(&mut self, +t: T) {
|
||||
self.push(t);
|
||||
self.push(move t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This is what the signature to spawn should look like with bare functions
|
||||
|
||||
fn spawn<T: Send>(val: T, f: extern fn(T)) {
|
||||
f(val);
|
||||
f(move val);
|
||||
}
|
||||
|
||||
fn f(+i: int) {
|
||||
|
@ -5,7 +5,7 @@ struct Foo {
|
||||
|
||||
fn main() {
|
||||
let a = Foo { x: 1, y: 2 };
|
||||
let c = Foo { x: 4, .. a };
|
||||
let c = Foo { x: 4, .. a};
|
||||
io::println(fmt!("%?", c));
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,6 @@ extern mod rusti {
|
||||
fn main() {
|
||||
let mut x = @1;
|
||||
let mut y = @2;
|
||||
rusti::move_val(&mut y, x);
|
||||
rusti::move_val(&mut y, move x);
|
||||
assert *y == 1;
|
||||
}
|
@ -28,7 +28,7 @@ fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
|
||||
do self.iter |a| {
|
||||
b <- blk(b, a);
|
||||
}
|
||||
return b;
|
||||
move b
|
||||
}
|
||||
|
||||
fn range(lo: uint, hi: uint, it: fn(uint)) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// tjc: I don't know why
|
||||
// xfail-pretty
|
||||
mod pipes {
|
||||
#[legacy_exports];
|
||||
use cast::{forget, transmute};
|
||||
@ -42,18 +44,18 @@ mod pipes {
|
||||
// We should consider moving this to core::unsafe, although I
|
||||
// suspect graydon would want us to use void pointers instead.
|
||||
unsafe fn uniquify<T>(+x: *T) -> ~T {
|
||||
unsafe { cast::transmute(x) }
|
||||
unsafe { cast::transmute(move x) }
|
||||
}
|
||||
|
||||
fn swap_state_acq(+dst: &mut state, src: state) -> state {
|
||||
unsafe {
|
||||
transmute(rusti::atomic_xchg_acq(transmute(dst), src as int))
|
||||
transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int))
|
||||
}
|
||||
}
|
||||
|
||||
fn swap_state_rel(+dst: &mut state, src: state) -> state {
|
||||
unsafe {
|
||||
transmute(rusti::atomic_xchg_rel(transmute(dst), src as int))
|
||||
transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int))
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,20 +63,20 @@ mod pipes {
|
||||
let p = p.unwrap();
|
||||
let p = unsafe { uniquify(p) };
|
||||
assert (*p).payload.is_none();
|
||||
(*p).payload <- Some(payload);
|
||||
(*p).payload <- Some(move payload);
|
||||
let old_state = swap_state_rel(&mut (*p).state, full);
|
||||
match old_state {
|
||||
empty => {
|
||||
// Yay, fastpath.
|
||||
|
||||
// The receiver will eventually clean this up.
|
||||
unsafe { forget(p); }
|
||||
unsafe { forget(move p); }
|
||||
}
|
||||
full => { fail ~"duplicate send" }
|
||||
blocked => {
|
||||
|
||||
// The receiver will eventually clean this up.
|
||||
unsafe { forget(p); }
|
||||
unsafe { forget(move p); }
|
||||
}
|
||||
terminated => {
|
||||
// The receiver will never receive this. Rely on drop_glue
|
||||
@ -94,7 +96,7 @@ mod pipes {
|
||||
full => {
|
||||
let mut payload = None;
|
||||
payload <-> (*p).payload;
|
||||
return Some(option::unwrap(payload))
|
||||
return Some(option::unwrap(move payload))
|
||||
}
|
||||
terminated => {
|
||||
assert old_state == terminated;
|
||||
@ -109,7 +111,7 @@ mod pipes {
|
||||
match swap_state_rel(&mut (*p).state, terminated) {
|
||||
empty | blocked => {
|
||||
// The receiver will eventually clean up.
|
||||
unsafe { forget(p) }
|
||||
unsafe { forget(move p) }
|
||||
}
|
||||
full => {
|
||||
// This is impossible
|
||||
@ -126,7 +128,7 @@ mod pipes {
|
||||
match swap_state_rel(&mut (*p).state, terminated) {
|
||||
empty => {
|
||||
// the sender will clean up
|
||||
unsafe { forget(p) }
|
||||
unsafe { forget(move p) }
|
||||
}
|
||||
blocked => {
|
||||
// this shouldn't happen.
|
||||
@ -144,7 +146,7 @@ mod pipes {
|
||||
if self.p != None {
|
||||
let mut p = None;
|
||||
p <-> self.p;
|
||||
sender_terminate(option::unwrap(p))
|
||||
sender_terminate(option::unwrap(move p))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,7 +155,7 @@ mod pipes {
|
||||
fn unwrap() -> *packet<T> {
|
||||
let mut p = None;
|
||||
p <-> self.p;
|
||||
option::unwrap(p)
|
||||
option::unwrap(move p)
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +171,7 @@ mod pipes {
|
||||
if self.p != None {
|
||||
let mut p = None;
|
||||
p <-> self.p;
|
||||
receiver_terminate(option::unwrap(p))
|
||||
receiver_terminate(option::unwrap(move p))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,7 +180,7 @@ mod pipes {
|
||||
fn unwrap() -> *packet<T> {
|
||||
let mut p = None;
|
||||
p <-> self.p;
|
||||
option::unwrap(p)
|
||||
option::unwrap(move p)
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,8 +206,8 @@ mod pingpong {
|
||||
ping(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
cast::forget(p);
|
||||
liberated_value
|
||||
cast::forget(move p);
|
||||
move liberated_value
|
||||
}
|
||||
|
||||
fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe {
|
||||
@ -213,8 +215,8 @@ mod pingpong {
|
||||
pong(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
cast::forget(p);
|
||||
liberated_value
|
||||
cast::forget(move p);
|
||||
move liberated_value
|
||||
}
|
||||
|
||||
fn init() -> (client::ping, server::ping) {
|
||||
@ -229,16 +231,16 @@ mod pingpong {
|
||||
fn do_ping(-c: ping) -> pong {
|
||||
let (sp, rp) = pipes::entangle();
|
||||
|
||||
pipes::send(c, ping(sp));
|
||||
rp
|
||||
pipes::send(move c, ping(move sp));
|
||||
move rp
|
||||
}
|
||||
|
||||
fn do_pong(-c: pong) -> (ping, ()) {
|
||||
let packet = pipes::recv(c);
|
||||
let packet = pipes::recv(move c);
|
||||
if packet.is_none() {
|
||||
fail ~"sender closed the connection"
|
||||
}
|
||||
(liberate_pong(option::unwrap(packet)), ())
|
||||
(liberate_pong(option::unwrap(move packet)), ())
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,32 +250,32 @@ mod pingpong {
|
||||
type pong = pipes::send_packet<pingpong::pong>;
|
||||
|
||||
fn do_ping(-c: ping) -> (pong, ()) {
|
||||
let packet = pipes::recv(c);
|
||||
let packet = pipes::recv(move c);
|
||||
if packet.is_none() {
|
||||
fail ~"sender closed the connection"
|
||||
}
|
||||
(liberate_ping(option::unwrap(packet)), ())
|
||||
(liberate_ping(option::unwrap(move packet)), ())
|
||||
}
|
||||
|
||||
fn do_pong(-c: pong) -> ping {
|
||||
let (sp, rp) = pipes::entangle();
|
||||
pipes::send(c, pong(sp));
|
||||
rp
|
||||
pipes::send(move c, pong(move sp));
|
||||
move rp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn client(-chan: pingpong::client::ping) {
|
||||
let chan = pingpong::client::do_ping(chan);
|
||||
let chan = pingpong::client::do_ping(move chan);
|
||||
log(error, ~"Sent ping");
|
||||
let (chan, _data) = pingpong::client::do_pong(chan);
|
||||
let (_chan, _data) = pingpong::client::do_pong(move chan);
|
||||
log(error, ~"Received pong");
|
||||
}
|
||||
|
||||
fn server(-chan: pingpong::server::ping) {
|
||||
let (chan, _data) = pingpong::server::do_ping(chan);
|
||||
let (chan, _data) = pingpong::server::do_ping(move chan);
|
||||
log(error, ~"Received ping");
|
||||
let chan = pingpong::server::do_pong(chan);
|
||||
let _chan = pingpong::server::do_pong(move chan);
|
||||
log(error, ~"Sent pong");
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ proto! streamp (
|
||||
|
||||
fn rendezvous() {
|
||||
let (c, s) = streamp::init();
|
||||
let streams: ~[streamp::client::open<int>] = ~[c];
|
||||
let streams: ~[streamp::client::open<int>] = ~[move c];
|
||||
|
||||
error!("%?", streams[0]);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fn square_from_char(c: char) -> square {
|
||||
}
|
||||
|
||||
fn read_board_grid<rdr: Owned io::Reader>(+in: rdr) -> ~[~[square]] {
|
||||
let in = in as io::Reader;
|
||||
let in = (move in) as io::Reader;
|
||||
let mut grid = ~[];
|
||||
for in.each_line |line| {
|
||||
let mut row = ~[];
|
||||
|
@ -7,5 +7,5 @@ proto! stream (
|
||||
fn main() {
|
||||
let (bc, _bp) = stream::init();
|
||||
|
||||
stream::client::send(bc, ~"abc");
|
||||
stream::client::send(move bc, ~"abc");
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
fn main() {
|
||||
let (c,p) = pipes::stream();
|
||||
do task::try {
|
||||
do task::try |move c| {
|
||||
let (c2,p2) = pipes::stream();
|
||||
do task::spawn {
|
||||
do task::spawn |move p2| {
|
||||
p2.recv();
|
||||
error!("brother fails");
|
||||
error!("sibling fails");
|
||||
fail;
|
||||
}
|
||||
let (c3,p3) = pipes::stream();
|
||||
c.send(c3);
|
||||
c.send(move c3);
|
||||
c2.send(());
|
||||
error!("child blocks");
|
||||
p3.recv();
|
||||
|
@ -4,19 +4,19 @@ use pipes::{Select2, Selectable};
|
||||
|
||||
fn main() {
|
||||
let (c,p) = pipes::stream();
|
||||
do task::try {
|
||||
do task::try |move c| {
|
||||
let (c2,p2) = pipes::stream();
|
||||
do task::spawn {
|
||||
do task::spawn |move p2| {
|
||||
p2.recv();
|
||||
error!("brother fails");
|
||||
error!("sibling fails");
|
||||
fail;
|
||||
}
|
||||
let (c3,p3) = pipes::stream();
|
||||
c.send(c3);
|
||||
c.send(move c3);
|
||||
c2.send(());
|
||||
error!("child blocks");
|
||||
let (c, p) = pipes::stream();
|
||||
(p, p3).select();
|
||||
(move p, move p3).select();
|
||||
c.send(());
|
||||
};
|
||||
error!("parent tries");
|
||||
|
@ -1,3 +1,4 @@
|
||||
// xfail-test
|
||||
struct P { child: Option<@mut P> }
|
||||
trait PTrait {
|
||||
fn getChildOption() -> Option<@P>;
|
||||
|
@ -1,5 +1,6 @@
|
||||
fn f(x:int) {
|
||||
const child: int = x + 1;
|
||||
}
|
||||
// xfail-test
|
||||
fn f(x:int) {
|
||||
const child: int = x + 1;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -5,7 +5,7 @@ fn main() {
|
||||
// Make sure closing over can be a last use
|
||||
let q = ~10;
|
||||
let addr = ptr::addr_of(&(*q));
|
||||
let f = fn@() -> *int { ptr::addr_of(&(*q)) };
|
||||
let f = fn@(move q) -> *int { ptr::addr_of(&(*q)) };
|
||||
assert addr == f();
|
||||
|
||||
// But only when it really is the last use
|
||||
|
@ -3,14 +3,14 @@
|
||||
fn lp<T>(s: ~str, f: fn(~str) -> T) -> T {
|
||||
while false {
|
||||
let r = f(s);
|
||||
return r;
|
||||
return (move r);
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn apply<T>(s: ~str, f: fn(~str) -> T) -> T {
|
||||
fn g<T>(s: ~str, f: fn(~str) -> T) -> T {f(s)}
|
||||
g(s, |v| { let r = f(v); r })
|
||||
g(s, |v| { let r = f(v); move r })
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -5,7 +5,7 @@ fn the_loop() {
|
||||
loop {
|
||||
let x = 5;
|
||||
if x > 3 {
|
||||
list += ~[take(x)];
|
||||
list += ~[take(move x)];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ type smallintmap<T> = @{mut v: ~[mut option<T>]};
|
||||
|
||||
fn mk<T>() -> smallintmap<T> {
|
||||
let v: ~[mut option<T>] = ~[mut];
|
||||
return @{mut v: v};
|
||||
return @{mut v: move v};
|
||||
}
|
||||
|
||||
fn f<T,U>() {
|
||||
|
@ -15,7 +15,7 @@ struct F<A> { a: A }
|
||||
|
||||
impl<A: Copy Serializable> F<A>: Serializable {
|
||||
fn serialize<S: Serializer>(s: S) {
|
||||
self.a.serialize(s);
|
||||
self.a.serialize(move s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ fn test(-foo: ~~[int]) { assert (foo[0] == 10); }
|
||||
fn main() {
|
||||
let x = ~~[10];
|
||||
// Test forgetting a local by move-in
|
||||
test(x);
|
||||
test(move x);
|
||||
|
||||
// Test forgetting a temporary by move-in.
|
||||
test(~~[10]);
|
||||
|
@ -3,7 +3,7 @@ fn test(-foo: @~[int]) { assert (foo[0] == 10); }
|
||||
fn main() {
|
||||
let x = @~[10];
|
||||
// Test forgetting a local by move-in
|
||||
test(x);
|
||||
test(move x);
|
||||
|
||||
// Test forgetting a temporary by move-in.
|
||||
test(@~[10]);
|
||||
|
@ -1,3 +1,3 @@
|
||||
fn test(-foo: int) { assert (foo == 10); }
|
||||
|
||||
fn main() { let x = 10; test(x); }
|
||||
fn main() { let x = 10; test(move x); }
|
||||
|
@ -2,7 +2,7 @@
|
||||
fn f2(-thing: fn@()) { }
|
||||
|
||||
fn f(-thing: fn@()) {
|
||||
f2(thing);
|
||||
f2(move thing);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -3,7 +3,7 @@ struct X {
|
||||
}
|
||||
|
||||
fn apply<T>(x: T, f: fn(T)) {
|
||||
f(x);
|
||||
f(move x);
|
||||
}
|
||||
|
||||
fn check_int(x: int) {
|
||||
|
@ -9,7 +9,7 @@ struct dtor {
|
||||
|
||||
fn unwrap<T>(+o: Option<T>) -> T {
|
||||
match move o {
|
||||
Some(move v) => v,
|
||||
Some(move v) => move v,
|
||||
None => fail
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ fn main() {
|
||||
|
||||
{
|
||||
let b = Some(dtor { x:x });
|
||||
let c = unwrap(b);
|
||||
let c = unwrap(move b);
|
||||
}
|
||||
|
||||
assert *x == 0;
|
||||
|
@ -33,15 +33,15 @@ proto! bank (
|
||||
)
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
|
||||
f: fn(+v: Option<T>) -> U) -> U {
|
||||
f(pipes::try_recv(endp))
|
||||
f(pipes::try_recv(move endp))
|
||||
}
|
||||
|
||||
fn move_it<T>(-x: T) -> T { x }
|
||||
fn move_it<T>(-x: T) -> T { move x }
|
||||
|
||||
macro_rules! follow (
|
||||
{
|
||||
@ -59,15 +59,15 @@ macro_rules! follow (
|
||||
fn client_follow(+bank: bank::client::login) {
|
||||
use bank::*;
|
||||
|
||||
let bank = client::login(bank, ~"theincredibleholk", ~"1234");
|
||||
let bank = switch(bank, follow! (
|
||||
ok -> connected { connected }
|
||||
let bank = client::login(move bank, ~"theincredibleholk", ~"1234");
|
||||
let bank = switch(move bank, follow! (
|
||||
ok -> connected { move connected }
|
||||
invalid -> _next { fail ~"bank closed the connected" }
|
||||
));
|
||||
|
||||
let bank = client::deposit(bank, 100.00);
|
||||
let bank = client::withdrawal(bank, 50.00);
|
||||
switch(bank, follow! (
|
||||
let bank = client::deposit(move bank, 100.00);
|
||||
let bank = client::withdrawal(move bank, 50.00);
|
||||
switch(move bank, follow! (
|
||||
money(m) -> _next {
|
||||
io::println(~"Yay! I got money!");
|
||||
}
|
||||
@ -80,8 +80,8 @@ fn client_follow(+bank: bank::client::login) {
|
||||
fn bank_client(+bank: bank::client::login) {
|
||||
use bank::*;
|
||||
|
||||
let bank = client::login(bank, ~"theincredibleholk", ~"1234");
|
||||
let bank = match try_recv(bank) {
|
||||
let bank = client::login(move bank, ~"theincredibleholk", ~"1234");
|
||||
let bank = match try_recv(move bank) {
|
||||
Some(ok(connected)) => {
|
||||
move_it!(connected)
|
||||
}
|
||||
@ -89,10 +89,10 @@ fn bank_client(+bank: bank::client::login) {
|
||||
None => { fail ~"bank closed the connection" }
|
||||
};
|
||||
|
||||
let bank = client::deposit(bank, 100.00);
|
||||
let bank = client::withdrawal(bank, 50.00);
|
||||
match try_recv(bank) {
|
||||
Some(money(m, _)) => {
|
||||
let bank = client::deposit(move bank, 100.00);
|
||||
let bank = client::withdrawal(move bank, 50.00);
|
||||
match try_recv(move bank) {
|
||||
Some(money(*)) => {
|
||||
io::println(~"Yay! I got money!");
|
||||
}
|
||||
Some(insufficient_funds(_)) => {
|
||||
|
@ -19,7 +19,7 @@ fn main() {
|
||||
let iotask = uv::global_loop::get();
|
||||
|
||||
pipes::spawn_service(oneshot::init, |p| {
|
||||
match try_recv(p) {
|
||||
match try_recv(move p) {
|
||||
Some(*) => { fail }
|
||||
None => { }
|
||||
}
|
||||
@ -34,11 +34,11 @@ fn main() {
|
||||
fn failtest() {
|
||||
let (c, p) = oneshot::init();
|
||||
|
||||
do task::spawn_with(c) |_c| {
|
||||
do task::spawn_with(move c) |_c| {
|
||||
fail;
|
||||
}
|
||||
|
||||
error!("%?", recv(p));
|
||||
error!("%?", recv(move p));
|
||||
// make sure we get killed if we missed it in the receive.
|
||||
loop { task::yield() }
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ fn main() {
|
||||
|
||||
assert !pipes::peek(&p);
|
||||
|
||||
oneshot::client::signal(c);
|
||||
oneshot::client::signal(move c);
|
||||
|
||||
assert pipes::peek(&p);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ mod pingpong {
|
||||
pong: mk_packet::<pong>()
|
||||
}
|
||||
};
|
||||
do pipes::entangle_buffer(buffer) |buffer, data| {
|
||||
do pipes::entangle_buffer(move buffer) |buffer, data| {
|
||||
data.ping.set_buffer_(buffer);
|
||||
data.pong.set_buffer_(buffer);
|
||||
ptr::addr_of(&(data.ping))
|
||||
@ -40,9 +40,9 @@ mod pingpong {
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let message = pingpong::ping(s);
|
||||
pipes::send(pipe, message);
|
||||
c
|
||||
let message = pingpong::ping(move s);
|
||||
pipes::send(move pipe, move message);
|
||||
move c
|
||||
}
|
||||
}
|
||||
type ping = pipes::SendPacketBuffered<pingpong::ping,
|
||||
@ -59,9 +59,9 @@ mod pingpong {
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let message = pingpong::pong(s);
|
||||
pipes::send(pipe, message);
|
||||
c
|
||||
let message = pingpong::pong(move s);
|
||||
pipes::send(move pipe, move message);
|
||||
move c
|
||||
}
|
||||
}
|
||||
type pong = pipes::SendPacketBuffered<pingpong::pong,
|
||||
@ -77,34 +77,34 @@ mod test {
|
||||
fn client(-chan: pingpong::client::ping) {
|
||||
use pingpong::client;
|
||||
|
||||
let chan = client::ping(chan); return;
|
||||
let chan = client::ping(move chan); return;
|
||||
log(error, "Sent ping");
|
||||
let pong(_chan) = recv(chan);
|
||||
let pong(_chan) = recv(move chan);
|
||||
log(error, "Received pong");
|
||||
}
|
||||
|
||||
fn server(-chan: pingpong::server::ping) {
|
||||
use pingpong::server;
|
||||
|
||||
let ping(chan) = recv(chan); return;
|
||||
let ping(chan) = recv(move chan); return;
|
||||
log(error, "Received ping");
|
||||
let _chan = server::pong(chan);
|
||||
let _chan = server::pong(move chan);
|
||||
log(error, "Sent pong");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (client_, server_) = pingpong::init();
|
||||
let client_ = ~mut Some(client_);
|
||||
let server_ = ~mut Some(server_);
|
||||
let client_ = ~mut Some(move client_);
|
||||
let server_ = ~mut Some(move server_);
|
||||
do task::spawn |move client_| {
|
||||
let mut client__ = None;
|
||||
*client_ <-> client__;
|
||||
test::client(option::unwrap(client__));
|
||||
test::client(option::unwrap(move client__));
|
||||
};
|
||||
do task::spawn |move server_| {
|
||||
let mut server_ˊ = None;
|
||||
*server_ <-> server_ˊ;
|
||||
test::server(option::unwrap(server_ˊ));
|
||||
test::server(option::unwrap(move server_ˊ));
|
||||
};
|
||||
}
|
||||
|
@ -20,35 +20,35 @@ mod test {
|
||||
fn client(-chan: pingpong::client::ping) {
|
||||
use pingpong::client;
|
||||
|
||||
let chan = client::ping(chan);
|
||||
let chan = client::ping(move chan);
|
||||
log(error, ~"Sent ping");
|
||||
let pong(_chan) = recv(chan);
|
||||
let pong(_chan) = recv(move chan);
|
||||
log(error, ~"Received pong");
|
||||
}
|
||||
|
||||
fn server(-chan: pingpong::server::ping) {
|
||||
use pingpong::server;
|
||||
|
||||
let ping(chan) = recv(chan);
|
||||
let ping(chan) = recv(move chan);
|
||||
log(error, ~"Received ping");
|
||||
let _chan = server::pong(chan);
|
||||
let _chan = server::pong(move chan);
|
||||
log(error, ~"Sent pong");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (client_, server_) = pingpong::init();
|
||||
let client_ = ~mut Some(client_);
|
||||
let server_ = ~mut Some(server_);
|
||||
let client_ = ~mut Some(move client_);
|
||||
let server_ = ~mut Some(move server_);
|
||||
|
||||
do task::spawn |move client_| {
|
||||
let mut client__ = None;
|
||||
*client_ <-> client__;
|
||||
test::client(option::unwrap(client__));
|
||||
test::client(option::unwrap(move client__));
|
||||
};
|
||||
do task::spawn |move server_| {
|
||||
let mut server_ˊ = None;
|
||||
*server_ <-> server_ˊ;
|
||||
test::server(option::unwrap(server_ˊ));
|
||||
test::server(option::unwrap(move server_ˊ));
|
||||
};
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ macro_rules! select_if (
|
||||
], )*
|
||||
} => {
|
||||
if $index == $count {
|
||||
match move pipes::try_recv($port) {
|
||||
match move pipes::try_recv(move $port) {
|
||||
$(Some($message($($(move $x,)+)* move next)) => {
|
||||
let $next = next;
|
||||
$e
|
||||
let $next = move next;
|
||||
move $e
|
||||
})+
|
||||
_ => fail
|
||||
}
|
||||
@ -90,33 +90,33 @@ fn render(_buffer: &Buffer) {
|
||||
}
|
||||
|
||||
fn draw_frame(+channel: double_buffer::client::acquire) {
|
||||
let channel = request(channel);
|
||||
let channel = request(move channel);
|
||||
select! (
|
||||
channel => {
|
||||
give_buffer(buffer) -> channel {
|
||||
render(&buffer);
|
||||
release(channel, move buffer)
|
||||
release(move channel, move buffer)
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_two_frames(+channel: double_buffer::client::acquire) {
|
||||
let channel = request(channel);
|
||||
let channel = request(move channel);
|
||||
let channel = select! (
|
||||
channel => {
|
||||
give_buffer(buffer) -> channel {
|
||||
render(&buffer);
|
||||
release(channel, move buffer)
|
||||
release(move channel, move buffer)
|
||||
}
|
||||
}
|
||||
);
|
||||
let channel = request(channel);
|
||||
let channel = request(move channel);
|
||||
select! (
|
||||
channel => {
|
||||
give_buffer(buffer) -> channel {
|
||||
render(&buffer);
|
||||
release(channel, move buffer)
|
||||
release(move channel, move buffer)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,3 +1,5 @@
|
||||
// tjc: un-xfail after snapshot
|
||||
// xfail-test
|
||||
// xfail-pretty
|
||||
|
||||
// Protocols
|
||||
|
@ -27,24 +27,24 @@ fn main() {
|
||||
|
||||
let c = pipes::spawn_service(stream::init, |p| {
|
||||
error!("waiting for pipes");
|
||||
let stream::send(x, p) = recv(p);
|
||||
let stream::send(x, p) = recv(move p);
|
||||
error!("got pipes");
|
||||
let (left, right) : (oneshot::server::waiting,
|
||||
oneshot::server::waiting)
|
||||
= x;
|
||||
= move x;
|
||||
error!("selecting");
|
||||
let (i, _, _) = select(~[left, right]);
|
||||
let (i, _, _) = select(~[move left, move right]);
|
||||
error!("selected");
|
||||
assert i == 0;
|
||||
|
||||
error!("waiting for pipes");
|
||||
let stream::send(x, _) = recv(p);
|
||||
let stream::send(x, _) = recv(move p);
|
||||
error!("got pipes");
|
||||
let (left, right) : (oneshot::server::waiting,
|
||||
oneshot::server::waiting)
|
||||
= x;
|
||||
= move x;
|
||||
error!("selecting");
|
||||
let (i, m, _) = select(~[left, right]);
|
||||
let (i, m, _) = select(~[move left, move right]);
|
||||
error!("selected %?", i);
|
||||
if m.is_some() {
|
||||
assert i == 1;
|
||||
@ -54,20 +54,20 @@ fn main() {
|
||||
let (c1, p1) = oneshot::init();
|
||||
let (_c2, p2) = oneshot::init();
|
||||
|
||||
let c = send(c, (p1, p2));
|
||||
let c = send(move c, (move p1, move p2));
|
||||
|
||||
sleep(iotask, 100);
|
||||
|
||||
signal(c1);
|
||||
signal(move c1);
|
||||
|
||||
let (_c1, p1) = oneshot::init();
|
||||
let (c2, p2) = oneshot::init();
|
||||
|
||||
send(c, (p1, p2));
|
||||
send(move c, (move p1, move p2));
|
||||
|
||||
sleep(iotask, 100);
|
||||
|
||||
signal(c2);
|
||||
signal(move c2);
|
||||
|
||||
test_select2();
|
||||
}
|
||||
@ -76,26 +76,26 @@ fn test_select2() {
|
||||
let (ac, ap) = stream::init();
|
||||
let (bc, bp) = stream::init();
|
||||
|
||||
stream::client::send(ac, 42);
|
||||
stream::client::send(move ac, 42);
|
||||
|
||||
match pipes::select2(ap, bp) {
|
||||
match pipes::select2(move ap, move bp) {
|
||||
either::Left(*) => { }
|
||||
either::Right(*) => { fail }
|
||||
}
|
||||
|
||||
stream::client::send(bc, ~"abc");
|
||||
stream::client::send(move bc, ~"abc");
|
||||
|
||||
error!("done with first select2");
|
||||
|
||||
let (ac, ap) = stream::init();
|
||||
let (bc, bp) = stream::init();
|
||||
|
||||
stream::client::send(bc, ~"abc");
|
||||
stream::client::send(move bc, ~"abc");
|
||||
|
||||
match pipes::select2(ap, bp) {
|
||||
match pipes::select2(move ap, move bp) {
|
||||
either::Left(*) => { fail }
|
||||
either::Right(*) => { }
|
||||
}
|
||||
|
||||
stream::client::send(ac, 42);
|
||||
stream::client::send(move ac, 42);
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ proto! oneshot (
|
||||
fn main() {
|
||||
use oneshot::client::*;
|
||||
|
||||
let c = pipes::spawn_service(oneshot::init, |p| { recv(p); });
|
||||
let c = pipes::spawn_service(oneshot::init, |p| { recv(move p); });
|
||||
|
||||
let iotask = uv::global_loop::get();
|
||||
sleep(iotask, 500);
|
||||
|
||||
signal(c);
|
||||
signal(move c);
|
||||
}
|
@ -2,8 +2,8 @@ struct closure_box {
|
||||
cl: &fn(),
|
||||
}
|
||||
|
||||
fn box_it(x: &r/fn()) -> closure_box/&r {
|
||||
closure_box {cl: x}
|
||||
fn box_it(+x: &r/fn()) -> closure_box/&r {
|
||||
closure_box {cl: move x}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -2,8 +2,8 @@ struct closure_box {
|
||||
cl: &fn(),
|
||||
}
|
||||
|
||||
fn box_it(x: &r/fn()) -> closure_box/&r {
|
||||
closure_box {cl: x}
|
||||
fn box_it(+x: &r/fn()) -> closure_box/&r {
|
||||
closure_box {cl: move x}
|
||||
}
|
||||
|
||||
fn call_static_closure(cl: closure_box/&static) {
|
||||
@ -12,5 +12,5 @@ fn call_static_closure(cl: closure_box/&static) {
|
||||
|
||||
fn main() {
|
||||
let cl_box = box_it(|| debug!("Hello, world!"));
|
||||
call_static_closure(cl_box);
|
||||
call_static_closure(move cl_box);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ fn main() {
|
||||
// Even though these look like copies, they are guaranteed not to be
|
||||
{
|
||||
let a = r(i);
|
||||
let b = (a, 10);
|
||||
let (c, _d) = b;
|
||||
let b = (move a, 10);
|
||||
let (c, _d) = move b;
|
||||
log(debug, c);
|
||||
}
|
||||
assert *i == 1;
|
||||
|
@ -24,10 +24,10 @@ enum t = {
|
||||
fn main() unsafe {
|
||||
let i1 = ~0;
|
||||
let i1p = cast::reinterpret_cast(&i1);
|
||||
cast::forget(i1);
|
||||
cast::forget(move i1);
|
||||
let i2 = ~0;
|
||||
let i2p = cast::reinterpret_cast(&i2);
|
||||
cast::forget(i2);
|
||||
cast::forget(move i2);
|
||||
|
||||
let x1 = @t({
|
||||
mut next: None,
|
||||
@ -35,7 +35,7 @@ fn main() unsafe {
|
||||
let rs = r(i1p);
|
||||
debug!("r = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
rs }
|
||||
move rs }
|
||||
});
|
||||
|
||||
debug!("x1 = %x, x1.r = %x",
|
||||
@ -48,7 +48,7 @@ fn main() unsafe {
|
||||
let rs = r(i2p);
|
||||
debug!("r2 = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
rs
|
||||
move rs
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -27,10 +27,10 @@ enum t = {
|
||||
fn main() unsafe {
|
||||
let i1 = ~0xA;
|
||||
let i1p = cast::reinterpret_cast(&i1);
|
||||
cast::forget(i1);
|
||||
cast::forget(move i1);
|
||||
let i2 = ~0xA;
|
||||
let i2p = cast::reinterpret_cast(&i2);
|
||||
cast::forget(i2);
|
||||
cast::forget(move i2);
|
||||
|
||||
let u1 = {a: 0xB, b: 0xC, c: i1p};
|
||||
let u2 = {a: 0xB, b: 0xC, c: i2p};
|
||||
|
@ -34,10 +34,10 @@ enum t = {
|
||||
fn main() unsafe {
|
||||
let i1 = ~0xA;
|
||||
let i1p = cast::reinterpret_cast(&i1);
|
||||
cast::forget(i1);
|
||||
cast::forget(move i1);
|
||||
let i2 = ~0xA;
|
||||
let i2p = cast::reinterpret_cast(&i2);
|
||||
cast::forget(i2);
|
||||
cast::forget(move i2);
|
||||
|
||||
let u1 = {a: 0xB, b: 0xC, c: i1p};
|
||||
let u2 = {a: 0xB, b: 0xC, c: i2p};
|
||||
|
@ -35,6 +35,6 @@ fn main() unsafe {
|
||||
};
|
||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(&f));
|
||||
rustrt::start_task(new_task_id, fptr);
|
||||
cast::forget(f);
|
||||
cast::forget(move f);
|
||||
comm::recv(po);
|
||||
}
|
||||
|
@ -17,18 +17,18 @@ macro_rules! select_if (
|
||||
$count:expr,
|
||||
$port:path => [
|
||||
$(type_this $message:path$(($(x $x: ident),+))dont_type_this*
|
||||
-> $next:ident => { $e:expr }),+
|
||||
-> $next:ident => { move $e:expr }),+
|
||||
]
|
||||
$(, $ports:path => [
|
||||
$(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
|
||||
-> $nexts:ident => { $es:expr }),+
|
||||
-> $nexts:ident => { move $es:expr }),+
|
||||
] )*
|
||||
} => {
|
||||
if $index == $count {
|
||||
match move pipes::try_recv($port) {
|
||||
$(Some($message($($(move $x,)+)* move next)) => {
|
||||
let $next = next;
|
||||
$e
|
||||
let $next = move next;
|
||||
move $e
|
||||
})+
|
||||
_ => fail
|
||||
}
|
||||
@ -38,7 +38,7 @@ macro_rules! select_if (
|
||||
$count + 1
|
||||
$(, $ports => [
|
||||
$(type_this $messages$(($(x $xs),+))dont_type_this*
|
||||
-> $nexts => { $es }),+
|
||||
-> $nexts => { move $es }),+
|
||||
])*
|
||||
)
|
||||
}
|
||||
@ -54,7 +54,7 @@ macro_rules! select (
|
||||
} => {
|
||||
let index = pipes::selecti([$(($port).header()),+]/_);
|
||||
select_if!(index, 0 $(, $port => [
|
||||
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
|
||||
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { move $e }),+
|
||||
])+)
|
||||
}
|
||||
)
|
||||
|
@ -13,13 +13,13 @@ fn andand<T: bool_like Copy>(x1: T, x2: T) -> T {
|
||||
|
||||
impl bool: bool_like {
|
||||
static fn select<A>(&&b: bool, +x1: A, +x2: A) -> A {
|
||||
if b { x1 } else { x2 }
|
||||
if b { move x1 } else { move x2 }
|
||||
}
|
||||
}
|
||||
|
||||
impl int: bool_like {
|
||||
static fn select<A>(&&b: int, +x1: A, +x2: A) -> A {
|
||||
if b != 0 { x1 } else { x2 }
|
||||
if b != 0 { move x1 } else { move x2 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ fn test05_start(ch : Chan<int>) {
|
||||
|
||||
fn test05() {
|
||||
let (ch, po) = pipes::stream();
|
||||
task::spawn(|| test05_start(ch) );
|
||||
task::spawn(|move ch| test05_start(ch) );
|
||||
let mut value = po.recv();
|
||||
log(error, value);
|
||||
value = po.recv();
|
||||
|
@ -5,7 +5,7 @@ extern mod std;
|
||||
|
||||
fn start(c: pipes::Chan<pipes::Chan<~str>>) {
|
||||
let (ch, p) = pipes::stream();
|
||||
c.send(ch);
|
||||
c.send(move ch);
|
||||
|
||||
let mut a;
|
||||
let mut b;
|
||||
@ -14,12 +14,12 @@ fn start(c: pipes::Chan<pipes::Chan<~str>>) {
|
||||
log(error, a);
|
||||
b = p.recv();
|
||||
assert b == ~"B";
|
||||
log(error, b);
|
||||
log(error, move b);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (ch, p) = pipes::stream();
|
||||
let child = task::spawn(|| start(ch) );
|
||||
let child = task::spawn(|move ch| start(ch) );
|
||||
|
||||
let c = p.recv();
|
||||
c.send(~"A");
|
||||
|
@ -5,11 +5,11 @@ extern mod std;
|
||||
|
||||
fn start(c: pipes::Chan<pipes::Chan<int>>) {
|
||||
let (ch, p) = pipes::stream();
|
||||
c.send(ch);
|
||||
c.send(move ch);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (ch, p) = pipes::stream();
|
||||
let child = task::spawn(|| start(ch) );
|
||||
let child = task::spawn(|move ch| start(ch) );
|
||||
let c = p.recv();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ fn start(&&task_number: int) { debug!("Started / Finished task."); }
|
||||
fn test00() {
|
||||
let i: int = 0;
|
||||
let mut result = None;
|
||||
do task::task().future_result(|+r| { result = Some(r); }).spawn {
|
||||
do task::task().future_result(|+r| { result = Some(move r); }).spawn {
|
||||
start(i)
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ fn test00() {
|
||||
}
|
||||
|
||||
// Try joining tasks that have already finished.
|
||||
future::get(&option::unwrap(result));
|
||||
future::get(&option::unwrap(move result));
|
||||
|
||||
debug!("Joined task.");
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ fn start(c: pipes::Chan<int>, start: int, number_of_messages: int) {
|
||||
fn main() {
|
||||
debug!("Check that we don't deadlock.");
|
||||
let (ch, p) = pipes::stream();
|
||||
task::try(|| start(ch, 0, 10) );
|
||||
task::try(|move ch| start(ch, 0, 10) );
|
||||
debug!("Joined task");
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ fn main() {
|
||||
while (i > 0) {
|
||||
log(debug, i);
|
||||
let (ch, p) = pipes::stream();
|
||||
po.add(p);
|
||||
task::spawn(|copy i| child(i, ch) );
|
||||
po.add(move p);
|
||||
task::spawn(|move ch, copy i| child(i, ch) );
|
||||
i = i - 1;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,6 @@ fn main() {
|
||||
// the child's point of view the receiver may die. We should
|
||||
// drop messages on the floor in this case, and not crash!
|
||||
let (ch, p) = pipes::stream();
|
||||
task::spawn(|| start(ch, 10));
|
||||
task::spawn(|move ch| start(ch, 10));
|
||||
p.recv();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ fn test_tag() {
|
||||
fn test_chan() {
|
||||
let (ch, po) = pipes::stream();
|
||||
let (ch0, po0) = pipes::stream();
|
||||
ch.send(ch0);
|
||||
ch.send(move ch0);
|
||||
let ch1 = po.recv();
|
||||
// Does the transmitted channel still work?
|
||||
|
||||
|
@ -34,8 +34,8 @@ fn test00() {
|
||||
while i < number_of_tasks {
|
||||
let ch = po.chan();
|
||||
do task::task().future_result(|+r| {
|
||||
results.push(r);
|
||||
}).spawn |copy i| {
|
||||
results.push(move r);
|
||||
}).spawn |move ch, copy i| {
|
||||
test00_start(ch, i, number_of_messages)
|
||||
}
|
||||
i = i + 1;
|
||||
|
@ -17,19 +17,19 @@ fn test00() {
|
||||
let number_of_messages: int = 10;
|
||||
|
||||
let c = p.chan();
|
||||
do task::spawn {
|
||||
do task::spawn |move c| {
|
||||
test00_start(c, number_of_messages * 0, number_of_messages);
|
||||
}
|
||||
let c = p.chan();
|
||||
do task::spawn {
|
||||
do task::spawn |move c| {
|
||||
test00_start(c, number_of_messages * 1, number_of_messages);
|
||||
}
|
||||
let c = p.chan();
|
||||
do task::spawn {
|
||||
do task::spawn |move c| {
|
||||
test00_start(c, number_of_messages * 2, number_of_messages);
|
||||
}
|
||||
let c = p.chan();
|
||||
do task::spawn {
|
||||
do task::spawn |move c| {
|
||||
test00_start(c, number_of_messages * 3, number_of_messages);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,8 @@ fn test00() {
|
||||
let ch = p.chan();
|
||||
|
||||
let mut result = None;
|
||||
do task::task().future_result(|+r| { result = Some(r); }).spawn {
|
||||
do task::task().future_result(|+r| { result = Some(move r); }).spawn
|
||||
|move ch| {
|
||||
test00_start(ch, number_of_messages);
|
||||
}
|
||||
|
||||
@ -29,7 +30,7 @@ fn test00() {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
future::get(&option::unwrap(result));
|
||||
future::get(&option::unwrap(move result));
|
||||
|
||||
assert (sum == number_of_messages * (number_of_messages - 1) / 2);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ fn test00() {
|
||||
while i < number_of_tasks {
|
||||
i = i + 1;
|
||||
do task::task().future_result(|+r| {
|
||||
results.push(r);
|
||||
results.push(move r);
|
||||
}).spawn |copy i| {
|
||||
test00_start(ch, i, number_of_messages);
|
||||
}
|
||||
@ -127,7 +127,7 @@ fn test06() {
|
||||
while i < number_of_tasks {
|
||||
i = i + 1;
|
||||
do task::task().future_result(|+r| {
|
||||
results.push(r);
|
||||
results.push(move r);
|
||||
}).spawn |copy i| {
|
||||
test06_start(i);
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ fn main() {
|
||||
assert indirect(~[10, 20]) == ~"[10, 20]!";
|
||||
|
||||
fn indirect2<T: to_str>(x: T) -> ~str {
|
||||
indirect(x)
|
||||
indirect(move x)
|
||||
}
|
||||
assert indirect2(~[1]) == ~"[1]!";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ fn f(-i: ~int) {
|
||||
|
||||
fn main() {
|
||||
let i = ~100;
|
||||
f(i);
|
||||
f(move i);
|
||||
}
|
@ -4,13 +4,13 @@ use task::*;
|
||||
|
||||
fn main() {
|
||||
let mut result = None;
|
||||
task::task().future_result(|+r| { result = Some(r); }).spawn(child);
|
||||
task::task().future_result(|+r| { result = Some(move r); }).spawn(child);
|
||||
error!("1");
|
||||
yield();
|
||||
error!("2");
|
||||
yield();
|
||||
error!("3");
|
||||
future::get(&option::unwrap(result));
|
||||
future::get(&option::unwrap(move result));
|
||||
}
|
||||
|
||||
fn child() {
|
||||
|
@ -4,10 +4,10 @@ use task::*;
|
||||
|
||||
fn main() {
|
||||
let mut result = None;
|
||||
task::task().future_result(|+r| { result = Some(r); }).spawn(child);
|
||||
task::task().future_result(|+r| { result = Some(move r); }).spawn(child);
|
||||
error!("1");
|
||||
yield();
|
||||
future::get(&option::unwrap(result));
|
||||
future::get(&option::unwrap(move result));
|
||||
}
|
||||
|
||||
fn child() { error!("2"); }
|
||||
|
Loading…
Reference in New Issue
Block a user