@@ -113,7 +113,7 @@ export send_packet, recv_packet, buffer_header;
113
113
const SPIN_COUNT : uint = 0 ;
114
114
115
115
macro_rules! move_it (
116
- { $x: expr } => { unsafe { let y <- * ptr:: addr_of( $x) ; y } }
116
+ { $x: expr } => { unsafe { let y <- * ptr:: addr_of( $x) ; move y } }
117
117
)
118
118
119
119
#[ doc( hidden) ]
@@ -262,8 +262,7 @@ fn unibuffer<T: Send>() -> ~Buffer<Packet<T>> {
262
262
unsafe {
263
263
b. data . header . buffer = reinterpret_cast ( & b) ;
264
264
}
265
-
266
- b
265
+ move b
267
266
}
268
267
269
268
#[ doc( hidden) ]
@@ -411,7 +410,7 @@ fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>,
411
410
let p = unsafe { & * p_ } ;
412
411
assert ptr:: addr_of ( p. header ) == header;
413
412
assert p. payload . is_none ( ) ;
414
- p. payload <- Some ( payload) ;
413
+ p. payload <- Some ( move payload) ;
415
414
let old_state = swap_state_rel ( & mut p. header . state , Full ) ;
416
415
match old_state {
417
416
Empty => {
@@ -449,7 +448,7 @@ Fails if the sender closes the connection.
449
448
450
449
*/
451
450
fn recv < T : Send , Tbuffer : Send > ( +p : RecvPacketBuffered < T , Tbuffer > ) -> T {
452
- option:: unwrap_expect ( try_recv ( p) , "connection closed" )
451
+ option:: unwrap_expect ( try_recv ( move p) , "connection closed" )
453
452
}
454
453
455
454
/** Attempts to receive a message from a pipe.
@@ -713,8 +712,8 @@ fn select2<A: Send, Ab: Send, B: Send, Bb: Send>(
713
712
let i = wait_many ( [ a. header ( ) , b. header ( ) ] /_) ;
714
713
715
714
match i {
716
- 0 => Left ( ( try_recv ( a) , b) ) ,
717
- 1 => Right ( ( a, try_recv ( b) ) ) ,
715
+ 0 => Left ( ( try_recv ( move a) , move b) ) ,
716
+ 1 => Right ( ( move a, try_recv ( move b) ) ) ,
718
717
_ => fail ~"select2 return an invalid packet"
719
718
}
720
719
}
@@ -750,10 +749,10 @@ fn select<T: Send, Tb: Send>(+endpoints: ~[RecvPacketBuffered<T, Tb>])
750
749
-> ( uint , Option < T > , ~[ RecvPacketBuffered < T , Tb > ] )
751
750
{
752
751
let ready = wait_many ( endpoints. map ( |p| p. header ( ) ) ) ;
753
- let mut remaining = endpoints;
752
+ let mut remaining <- endpoints;
754
753
let port = vec:: swap_remove ( remaining, ready) ;
755
- let result = try_recv ( port) ;
756
- ( ready, result, remaining)
754
+ let result = try_recv ( move port) ;
755
+ ( ready, move result, move remaining)
757
756
}
758
757
759
758
/** The sending end of a pipe. It can be used to send exactly one
@@ -943,14 +942,14 @@ fn spawn_service<T: Send, Tb: Send>(
943
942
944
943
// This is some nasty gymnastics required to safely move the pipe
945
944
// into a new task.
946
- let server = ~mut Some ( server) ;
947
- do task:: spawn |move service| {
945
+ let server = ~mut Some ( move server) ;
946
+ do task:: spawn |move service, move server | {
948
947
let mut server_ = None ;
949
948
server_ <-> * server;
950
949
service ( option:: unwrap ( server_) )
951
950
}
952
951
953
- client
952
+ move client
954
953
}
955
954
956
955
/** Like `spawn_service_recv`, but for protocols that start in the
@@ -967,14 +966,14 @@ fn spawn_service_recv<T: Send, Tb: Send>(
967
966
968
967
// This is some nasty gymnastics required to safely move the pipe
969
968
// into a new task.
970
- let server = ~mut Some ( server) ;
971
- do task:: spawn |move service| {
969
+ let server = ~mut Some ( move server) ;
970
+ do task:: spawn |move service, move server | {
972
971
let mut server_ = None ;
973
972
server_ <-> * server;
974
973
service ( option:: unwrap ( server_) )
975
974
}
976
975
977
- client
976
+ move client
978
977
}
979
978
980
979
// Streams - Make pipes a little easier in general.
@@ -1039,23 +1038,23 @@ These allow sending or receiving an unlimited number of messages.
1039
1038
fn stream < T : Send > ( ) -> ( Chan < T > , Port < T > ) {
1040
1039
let ( c, s) = streamp:: init ( ) ;
1041
1040
1042
- ( Chan_ ( { mut endp: Some ( c) } ) , Port_ ( { mut endp: Some ( s) } ) )
1041
+ ( Chan_ ( { mut endp: Some ( move c) } ) , Port_ ( { mut endp: Some ( move s) } ) )
1043
1042
}
1044
1043
1045
1044
impl < T : Send > Chan < T > : Channel < T > {
1046
1045
fn send ( +x : T ) {
1047
1046
let mut endp = None ;
1048
1047
endp <-> self . endp ;
1049
1048
self . endp = Some (
1050
- streamp:: client:: data ( unwrap ( endp) , x) )
1049
+ streamp:: client:: data ( unwrap ( endp) , move x) )
1051
1050
}
1052
1051
1053
1052
fn try_send ( +x : T ) -> bool {
1054
1053
let mut endp = None ;
1055
1054
endp <-> self . endp ;
1056
- match move streamp:: client:: try_data ( unwrap ( endp) , x) {
1055
+ match move streamp:: client:: try_data ( unwrap ( endp) , move x) {
1057
1056
Some ( move next) => {
1058
- self . endp = Some ( next) ;
1057
+ self . endp = Some ( move next) ;
1059
1058
true
1060
1059
}
1061
1060
None => false
@@ -1068,17 +1067,17 @@ impl<T: Send> Port<T>: Recv<T> {
1068
1067
let mut endp = None ;
1069
1068
endp <-> self . endp ;
1070
1069
let streamp:: data( x, endp) = pipes:: recv ( unwrap ( endp) ) ;
1071
- self . endp = Some ( endp) ;
1072
- x
1070
+ self . endp = Some ( move endp) ;
1071
+ move x
1073
1072
}
1074
1073
1075
1074
fn try_recv ( ) -> Option < T > {
1076
1075
let mut endp = None ;
1077
1076
endp <-> self . endp ;
1078
1077
match move pipes:: try_recv ( unwrap ( endp) ) {
1079
1078
Some ( streamp:: data( move x, move endp) ) => {
1080
- self . endp = Some ( endp) ;
1081
- Some ( x)
1079
+ self . endp = Some ( move endp) ;
1080
+ Some ( move x)
1082
1081
}
1083
1082
None => None
1084
1083
}
@@ -1101,13 +1100,13 @@ struct PortSet<T: Send> : Recv<T> {
1101
1100
mut ports : ~[ pipes:: Port < T > ] ,
1102
1101
1103
1102
fn add( +port : pipes:: Port < T > ) {
1104
- vec:: push ( self . ports , port )
1103
+ vec:: push ( self . ports , move port)
1105
1104
}
1106
1105
1107
1106
fn chan ( ) -> Chan < T > {
1108
1107
let ( ch , po ) = stream( ) ;
1109
- self . add ( po) ;
1110
- ch
1108
+ self . add ( move po) ;
1109
+ move ch
1111
1110
}
1112
1111
1113
1112
fn try_recv ( ) -> Option < T > {
@@ -1120,7 +1119,7 @@ struct PortSet<T: Send> : Recv<T> {
1120
1119
let i = wait_many ( ports) ;
1121
1120
match move ports[ i] . try_recv ( ) {
1122
1121
Some ( move m) => {
1123
- result = Some ( m) ;
1122
+ result = Some ( move m) ;
1124
1123
}
1125
1124
None => {
1126
1125
// Remove this port.
@@ -1129,7 +1128,7 @@ struct PortSet<T: Send> : Recv<T> {
1129
1128
}
1130
1129
}
1131
1130
ports <-> self . ports ;
1132
- result
1131
+ move result
1133
1132
}
1134
1133
1135
1134
fn recv ( ) -> T {
@@ -1166,7 +1165,7 @@ type SharedChan<T: Send> = unsafe::Exclusive<Chan<T>>;
1166
1165
1167
1166
impl < T : Send > SharedChan < T > : Channel < T > {
1168
1167
fn send ( +x : T ) {
1169
- let mut xx = Some ( x) ;
1168
+ let mut xx = Some ( move x) ;
1170
1169
do self. with |chan| {
1171
1170
let mut x = None ;
1172
1171
x <-> xx;
@@ -1175,7 +1174,7 @@ impl<T: Send> SharedChan<T>: Channel<T> {
1175
1174
}
1176
1175
1177
1176
fn try_send ( +x : T ) -> bool {
1178
- let mut xx = Some ( x) ;
1177
+ let mut xx = Some ( move x) ;
1179
1178
do self. with |chan| {
1180
1179
let mut x = None ;
1181
1180
x <-> xx;
@@ -1186,7 +1185,7 @@ impl<T: Send> SharedChan<T>: Channel<T> {
1186
1185
1187
1186
/// Converts a `chan` into a `shared_chan`.
1188
1187
fn SharedChan < T : Send > ( +c : Chan < T > ) -> SharedChan < T > {
1189
- unsafe :: exclusive ( c)
1188
+ unsafe :: exclusive ( move c)
1190
1189
}
1191
1190
1192
1191
/// Receive a message from one of two endpoints.
@@ -1240,24 +1239,24 @@ fn oneshot<T: Send>() -> (ChanOne<T>, PortOne<T>) {
1240
1239
* closed.
1241
1240
*/
1242
1241
fn recv_one < T : Send > ( +port : PortOne < T > ) -> T {
1243
- let oneshot:: send( message) = recv ( port) ;
1244
- message
1242
+ let oneshot:: send( message) = recv ( move port) ;
1243
+ move message
1245
1244
}
1246
1245
1247
1246
/// Receive a message from a oneshot pipe unless the connection was closed.
1248
1247
fn try_recv_one < T : Send > ( +port : PortOne < T > ) -> Option < T > {
1249
- let message = try_recv ( port) ;
1248
+ let message = try_recv ( move port) ;
1250
1249
1251
1250
if message. is_none ( ) { None }
1252
1251
else {
1253
1252
let oneshot:: send( message) = option:: unwrap ( message) ;
1254
- Some ( message)
1253
+ Some ( move message)
1255
1254
}
1256
1255
}
1257
1256
1258
1257
/// Send a message on a oneshot pipe, failing if the connection was closed.
1259
1258
fn send_one < T : Send > ( +chan : ChanOne < T > , +data : T ) {
1260
- oneshot:: client:: send ( chan, data) ;
1259
+ oneshot:: client:: send ( move chan, move data) ;
1261
1260
}
1262
1261
1263
1262
/**
@@ -1266,13 +1265,13 @@ fn send_one<T: Send>(+chan: ChanOne<T>, +data: T) {
1266
1265
*/
1267
1266
fn try_send_one < T : Send > ( +chan : ChanOne < T > , +data : T )
1268
1267
-> bool {
1269
- oneshot:: client:: try_send ( chan, data) . is_some ( )
1268
+ oneshot:: client:: try_send ( move chan, move data) . is_some ( )
1270
1269
}
1271
1270
1272
1271
mod rt {
1273
1272
// These are used to hide the option constructors from the
1274
1273
// compiler because their names are changing
1275
- fn make_some < T > ( +val : T ) -> Option < T > { Some ( val) }
1274
+ fn make_some < T > ( +val : T ) -> Option < T > { Some ( move val) }
1276
1275
fn make_none < T > ( ) -> Option < T > { None }
1277
1276
}
1278
1277
0 commit comments