@@ -32,8 +32,8 @@ will once again be the preferred module for intertask communication.
32
32
33
33
*/
34
34
35
- // NB: transitionary, de-mode-ing
36
- // tjc: re- forbid deprecated modes after snapshot
35
+ // NB: transitionary, de-mode-ing.
36
+ # [ forbid( deprecated_mode ) ] ;
37
37
#[ forbid( deprecated_pattern) ] ;
38
38
39
39
use either:: Either ;
@@ -74,7 +74,7 @@ pub fn Port<T: Send>() -> Port<T> {
74
74
75
75
impl < T : Send > Port < T > {
76
76
77
- fn chan ( ) -> Chan < T > { Chan ( self ) }
77
+ fn chan ( ) -> Chan < T > { Chan ( & self ) }
78
78
fn send ( v : T ) { self . chan ( ) . send ( move v) }
79
79
fn recv ( ) -> T { recv ( self ) }
80
80
fn peek ( ) -> bool { peek ( self ) }
@@ -166,7 +166,7 @@ fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
166
166
* Constructs a channel. The channel is bound to the port used to
167
167
* construct it.
168
168
*/
169
- pub fn Chan < T : Send > ( & & p: Port < T > ) -> Chan < T > {
169
+ pub fn Chan < T : Send > ( p : & Port < T > ) -> Chan < T > {
170
170
Chan_ ( rustrt:: get_port_id ( ( * * p) . po ) )
171
171
}
172
172
@@ -304,51 +304,51 @@ extern mod rusti {
304
304
305
305
306
306
#[ test]
307
- fn create_port_and_chan ( ) { let p = Port :: < int > ( ) ; Chan ( p) ; }
307
+ fn create_port_and_chan ( ) { let p = Port :: < int > ( ) ; Chan ( & p) ; }
308
308
309
309
#[ test]
310
310
fn send_int ( ) {
311
311
let p = Port :: < int > ( ) ;
312
- let c = Chan ( p) ;
312
+ let c = Chan ( & p) ;
313
313
send ( c, 22 ) ;
314
314
}
315
315
316
316
#[ test]
317
317
fn send_recv_fn ( ) {
318
318
let p = Port :: < int > ( ) ;
319
- let c = Chan :: < int > ( p) ;
319
+ let c = Chan :: < int > ( & p) ;
320
320
send ( c, 42 ) ;
321
321
assert ( recv ( p) == 42 ) ;
322
322
}
323
323
324
324
#[ test]
325
325
fn send_recv_fn_infer ( ) {
326
326
let p = Port ( ) ;
327
- let c = Chan ( p) ;
327
+ let c = Chan ( & p) ;
328
328
send ( c, 42 ) ;
329
329
assert ( recv ( p) == 42 ) ;
330
330
}
331
331
332
332
#[ test]
333
333
fn chan_chan_infer ( ) {
334
334
let p = Port ( ) , p2 = Port :: < int > ( ) ;
335
- let c = Chan ( p) ;
336
- send ( c, Chan ( p2) ) ;
335
+ let c = Chan ( & p) ;
336
+ send ( c, Chan ( & p2) ) ;
337
337
recv ( p) ;
338
338
}
339
339
340
340
#[ test]
341
341
fn chan_chan ( ) {
342
342
let p = Port :: < Chan < int > > ( ) , p2 = Port :: < int > ( ) ;
343
- let c = Chan ( p) ;
344
- send ( c, Chan ( p2) ) ;
343
+ let c = Chan ( & p) ;
344
+ send ( c, Chan ( & p2) ) ;
345
345
recv ( p) ;
346
346
}
347
347
348
348
#[ test]
349
349
fn test_peek ( ) {
350
350
let po = Port ( ) ;
351
- let ch = Chan ( po) ;
351
+ let ch = Chan ( & po) ;
352
352
assert ! peek( po) ;
353
353
send ( ch, ( ) ) ;
354
354
assert peek( po) ;
@@ -360,8 +360,8 @@ fn test_peek() {
360
360
fn test_select2_available ( ) {
361
361
let po_a = Port ( ) ;
362
362
let po_b = Port ( ) ;
363
- let ch_a = Chan ( po_a) ;
364
- let ch_b = Chan ( po_b) ;
363
+ let ch_a = Chan ( & po_a) ;
364
+ let ch_b = Chan ( & po_b) ;
365
365
366
366
send ( ch_a, ~"a") ;
367
367
@@ -376,8 +376,8 @@ fn test_select2_available() {
376
376
fn test_select2_rendezvous() {
377
377
let po_a = Port();
378
378
let po_b = Port();
379
- let ch_a = Chan(po_a);
380
- let ch_b = Chan(po_b);
379
+ let ch_a = Chan(& po_a);
380
+ let ch_b = Chan(& po_b);
381
381
382
382
for iter::repeat(10) {
383
383
do task::spawn {
@@ -400,8 +400,8 @@ fn test_select2_rendezvous() {
400
400
fn test_select2_stress() {
401
401
let po_a = Port();
402
402
let po_b = Port();
403
- let ch_a = Chan(po_a);
404
- let ch_b = Chan(po_b);
403
+ let ch_a = Chan(& po_a);
404
+ let ch_b = Chan(& po_b);
405
405
406
406
let msgs = 100;
407
407
let times = 4u;
@@ -436,7 +436,7 @@ fn test_select2_stress() {
436
436
#[ test]
437
437
fn test_recv_chan( ) {
438
438
let po = Port ( ) ;
439
- let ch = Chan ( po) ;
439
+ let ch = Chan ( & po) ;
440
440
send( ch, ~"flower") ;
441
441
assert recv_chan( ch) == ~"flower";
442
442
}
@@ -445,7 +445,7 @@ fn test_recv_chan() {
445
445
#[ should_fail]
446
446
#[ ignore( cfg( windows) ) ]
447
447
fn test_recv_chan_dead( ) {
448
- let ch = Chan ( Port ( ) ) ;
448
+ let ch = Chan ( & Port ( ) ) ;
449
449
send( ch, ~"flower") ;
450
450
recv_chan( ch) ;
451
451
}
@@ -454,7 +454,7 @@ fn test_recv_chan_dead() {
454
454
#[ ignore( cfg( windows) ) ]
455
455
fn test_recv_chan_wrong_task( ) {
456
456
let po = Port ( ) ;
457
- let ch = Chan ( po) ;
457
+ let ch = Chan ( & po) ;
458
458
send( ch, ~"flower") ;
459
459
assert result:: is_err( & task:: try( ||
460
460
recv_chan( ch)
0 commit comments