9
9
ready,
10
10
stream:: { Stream , StreamExt } ,
11
11
sink:: Sink ,
12
- task:: { LocalWaker , Poll } ,
12
+ task:: { Waker , Poll } ,
13
13
} ,
14
- futures_test:: task:: noop_local_waker_ref ,
14
+ futures_test:: task:: noop_waker_ref ,
15
15
std:: pin:: Pin ,
16
16
} ;
17
17
18
18
/// Single producer, single consumer
19
19
#[ bench]
20
20
fn unbounded_1_tx ( b : & mut Bencher ) {
21
- let lw = noop_local_waker_ref ( ) ;
21
+ let waker = noop_waker_ref ( ) ;
22
22
b. iter ( || {
23
23
let ( tx, mut rx) = mpsc:: unbounded ( ) ;
24
24
@@ -27,20 +27,20 @@ fn unbounded_1_tx(b: &mut Bencher) {
27
27
for i in 0 ..1000 {
28
28
29
29
// Poll, not ready, park
30
- assert_eq ! ( Poll :: Pending , rx. poll_next_unpin( lw ) ) ;
30
+ assert_eq ! ( Poll :: Pending , rx. poll_next_unpin( waker ) ) ;
31
31
32
32
UnboundedSender :: unbounded_send ( & tx, i) . unwrap ( ) ;
33
33
34
34
// Now poll ready
35
- assert_eq ! ( Poll :: Ready ( Some ( i) ) , rx. poll_next_unpin( lw ) ) ;
35
+ assert_eq ! ( Poll :: Ready ( Some ( i) ) , rx. poll_next_unpin( waker ) ) ;
36
36
}
37
37
} )
38
38
}
39
39
40
40
/// 100 producers, single consumer
41
41
#[ bench]
42
42
fn unbounded_100_tx ( b : & mut Bencher ) {
43
- let lw = noop_local_waker_ref ( ) ;
43
+ let waker = noop_waker_ref ( ) ;
44
44
b. iter ( || {
45
45
let ( tx, mut rx) = mpsc:: unbounded ( ) ;
46
46
@@ -49,26 +49,26 @@ fn unbounded_100_tx(b: &mut Bencher) {
49
49
// 1000 send/recv operations total, result should be divided by 1000
50
50
for _ in 0 ..10 {
51
51
for i in 0 ..tx. len ( ) {
52
- assert_eq ! ( Poll :: Pending , rx. poll_next_unpin( lw ) ) ;
52
+ assert_eq ! ( Poll :: Pending , rx. poll_next_unpin( waker ) ) ;
53
53
54
54
UnboundedSender :: unbounded_send ( & tx[ i] , i) . unwrap ( ) ;
55
55
56
- assert_eq ! ( Poll :: Ready ( Some ( i) ) , rx. poll_next_unpin( lw ) ) ;
56
+ assert_eq ! ( Poll :: Ready ( Some ( i) ) , rx. poll_next_unpin( waker ) ) ;
57
57
}
58
58
}
59
59
} )
60
60
}
61
61
62
62
#[ bench]
63
63
fn unbounded_uncontended ( b : & mut Bencher ) {
64
- let lw = noop_local_waker_ref ( ) ;
64
+ let waker = noop_waker_ref ( ) ;
65
65
b. iter ( || {
66
66
let ( tx, mut rx) = mpsc:: unbounded ( ) ;
67
67
68
68
for i in 0 ..1000 {
69
69
UnboundedSender :: unbounded_send ( & tx, i) . expect ( "send" ) ;
70
70
// No need to create a task, because poll is not going to park.
71
- assert_eq ! ( Poll :: Ready ( Some ( i) ) , rx. poll_next_unpin( lw ) ) ;
71
+ assert_eq ! ( Poll :: Ready ( Some ( i) ) , rx. poll_next_unpin( waker ) ) ;
72
72
}
73
73
} )
74
74
}
@@ -84,41 +84,41 @@ struct TestSender {
84
84
impl Stream for TestSender {
85
85
type Item = u32 ;
86
86
87
- fn poll_next ( mut self : Pin < & mut Self > , lw : & LocalWaker )
87
+ fn poll_next ( mut self : Pin < & mut Self > , waker : & Waker )
88
88
-> Poll < Option < Self :: Item > >
89
89
{
90
90
let this = & mut * self ;
91
91
let mut tx = Pin :: new ( & mut this. tx ) ;
92
92
93
- ready ! ( tx. as_mut( ) . poll_ready( lw ) ) . unwrap ( ) ;
93
+ ready ! ( tx. as_mut( ) . poll_ready( waker ) ) . unwrap ( ) ;
94
94
tx. as_mut ( ) . start_send ( this. last + 1 ) . unwrap ( ) ;
95
95
this. last += 1 ;
96
- assert_eq ! ( Poll :: Ready ( Ok ( ( ) ) ) , tx. as_mut( ) . poll_flush( lw ) ) ;
96
+ assert_eq ! ( Poll :: Ready ( Ok ( ( ) ) ) , tx. as_mut( ) . poll_flush( waker ) ) ;
97
97
Poll :: Ready ( Some ( this. last ) )
98
98
}
99
99
}
100
100
101
101
/// Single producers, single consumer
102
102
#[ bench]
103
103
fn bounded_1_tx ( b : & mut Bencher ) {
104
- let lw = noop_local_waker_ref ( ) ;
104
+ let waker = noop_waker_ref ( ) ;
105
105
b. iter ( || {
106
106
let ( tx, mut rx) = mpsc:: channel ( 0 ) ;
107
107
108
108
let mut tx = TestSender { tx, last : 0 } ;
109
109
110
110
for i in 0 ..1000 {
111
- assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , tx. poll_next_unpin( lw ) ) ;
112
- assert_eq ! ( Poll :: Pending , tx. poll_next_unpin( lw ) ) ;
113
- assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , rx. poll_next_unpin( lw ) ) ;
111
+ assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , tx. poll_next_unpin( waker ) ) ;
112
+ assert_eq ! ( Poll :: Pending , tx. poll_next_unpin( waker ) ) ;
113
+ assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , rx. poll_next_unpin( waker ) ) ;
114
114
}
115
115
} )
116
116
}
117
117
118
118
/// 100 producers, single consumer
119
119
#[ bench]
120
120
fn bounded_100_tx ( b : & mut Bencher ) {
121
- let lw = noop_local_waker_ref ( ) ;
121
+ let waker = noop_waker_ref ( ) ;
122
122
b. iter ( || {
123
123
// Each sender can send one item after specified capacity
124
124
let ( tx, mut rx) = mpsc:: channel ( 0 ) ;
@@ -133,11 +133,11 @@ fn bounded_100_tx(b: &mut Bencher) {
133
133
for i in 0 ..10 {
134
134
for j in 0 ..tx. len ( ) {
135
135
// Send an item
136
- assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , tx[ j] . poll_next_unpin( lw ) ) ;
136
+ assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , tx[ j] . poll_next_unpin( waker ) ) ;
137
137
// Then block
138
- assert_eq ! ( Poll :: Pending , tx[ j] . poll_next_unpin( lw ) ) ;
138
+ assert_eq ! ( Poll :: Pending , tx[ j] . poll_next_unpin( waker ) ) ;
139
139
// Recv the item
140
- assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , rx. poll_next_unpin( lw ) ) ;
140
+ assert_eq ! ( Poll :: Ready ( Some ( i + 1 ) ) , rx. poll_next_unpin( waker ) ) ;
141
141
}
142
142
}
143
143
} )
0 commit comments