1
1
use super :: * ;
2
2
3
+ use std:: task:: { Context , Waker } ;
3
4
use std:: usize;
4
5
5
6
#[ derive( Debug ) ]
@@ -25,6 +26,11 @@ pub(super) struct Counts {
25
26
26
27
/// Current number of pending locally reset streams
27
28
num_reset_streams : usize ,
29
+
30
+ /// If remote settings were applied
31
+ remote_settings_applied : bool ,
32
+
33
+ remote_settings_applied_task : Option < Waker > ,
28
34
}
29
35
30
36
impl Counts {
@@ -38,6 +44,8 @@ impl Counts {
38
44
num_recv_streams : 0 ,
39
45
max_reset_streams : config. local_reset_max ,
40
46
num_reset_streams : 0 ,
47
+ remote_settings_applied : false ,
48
+ remote_settings_applied_task : None ,
41
49
}
42
50
}
43
51
@@ -108,6 +116,8 @@ impl Counts {
108
116
if let Some ( val) = settings. max_concurrent_streams ( ) {
109
117
self . max_send_streams = val as usize ;
110
118
}
119
+ self . remote_settings_applied = true ;
120
+ self . notify_remote_settings_applied ( )
111
121
}
112
122
113
123
/// Run a block of code that could potentially transition a stream's state.
@@ -173,6 +183,16 @@ impl Counts {
173
183
self . max_send_streams
174
184
}
175
185
186
+ /// Returns if remote settings were applied
187
+ pub ( crate ) fn remote_settings_applied ( & self ) -> bool {
188
+ self . remote_settings_applied
189
+ }
190
+
191
+ /// Sets waker task for remote settings being set
192
+ pub ( crate ) fn wait_remote_settings_applied ( & mut self , cx : & Context ) {
193
+ self . remote_settings_applied_task = Some ( cx. waker ( ) . clone ( ) ) ;
194
+ }
195
+
176
196
/// Returns the maximum number of streams that can be initiated by the
177
197
/// remote peer.
178
198
pub ( crate ) fn max_recv_streams ( & self ) -> usize {
@@ -197,6 +217,12 @@ impl Counts {
197
217
assert ! ( self . num_reset_streams > 0 ) ;
198
218
self . num_reset_streams -= 1 ;
199
219
}
220
+
221
+ fn notify_remote_settings_applied ( & mut self ) {
222
+ if let Some ( task) = self . remote_settings_applied_task . take ( ) {
223
+ task. wake ( ) ;
224
+ }
225
+ }
200
226
}
201
227
202
228
impl Drop for Counts {
0 commit comments