File tree 1 file changed +8
-9
lines changed
1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 20
20
use std:: sync:: mpsc:: channel;
21
21
use std:: os;
22
22
use std:: thread:: Thread ;
23
- use std:: uint;
24
23
25
24
// This is a simple bench that creates M pairs of tasks. These
26
25
// tasks ping-pong back and forth over a pair of streams. This is a
@@ -31,24 +30,24 @@ fn ping_pong_bench(n: uint, m: uint) {
31
30
32
31
// Create pairs of tasks that pingpong back and forth.
33
32
fn run_pair ( n : uint ) {
34
- // Create a stream A->B
35
- let ( atx, arx) = channel :: < ( ) > ( ) ;
36
- // Create a stream B->A
37
- let ( btx, brx) = channel :: < ( ) > ( ) ;
33
+ // Create a channel: A->B
34
+ let ( atx, arx) = channel ( ) ;
35
+ // Create a channel: B->A
36
+ let ( btx, brx) = channel ( ) ;
38
37
39
38
Thread :: spawn ( move || {
40
39
let ( tx, rx) = ( atx, brx) ;
41
40
for _ in range ( 0 , n) {
42
- tx. send ( ( ) ) ;
43
- rx. recv ( ) ;
41
+ tx. send ( ( ) ) . unwrap ( ) ;
42
+ rx. recv ( ) . unwrap ( ) ;
44
43
}
45
44
} ) . detach ( ) ;
46
45
47
46
Thread :: spawn ( move || {
48
47
let ( tx, rx) = ( btx, arx) ;
49
48
for _ in range ( 0 , n) {
50
- rx. recv ( ) ;
51
- tx. send ( ( ) ) ;
49
+ rx. recv ( ) . unwrap ( ) ;
50
+ tx. send ( ( ) ) . unwrap ( ) ;
52
51
}
53
52
} ) . detach ( ) ;
54
53
}
You can’t perform that action at this time.
0 commit comments