11use super :: * ;
22
3+ use std:: task:: { Context , Waker } ;
34use std:: usize;
45
56#[ derive( Debug ) ]
@@ -25,6 +26,11 @@ pub(super) struct Counts {
2526
2627 /// Current number of pending locally reset streams
2728 num_reset_streams : usize ,
29+
30+ /// If remote settings were applied
31+ remote_settings_applied : bool ,
32+
33+ remote_settings_applied_task : Option < Waker > ,
2834}
2935
3036impl Counts {
@@ -38,6 +44,8 @@ impl Counts {
3844 num_recv_streams : 0 ,
3945 max_reset_streams : config. local_reset_max ,
4046 num_reset_streams : 0 ,
47+ remote_settings_applied : false ,
48+ remote_settings_applied_task : None ,
4149 }
4250 }
4351
@@ -108,6 +116,8 @@ impl Counts {
108116 if let Some ( val) = settings. max_concurrent_streams ( ) {
109117 self . max_send_streams = val as usize ;
110118 }
119+ self . remote_settings_applied = true ;
120+ self . notify_remote_settings_applied ( )
111121 }
112122
113123 /// Run a block of code that could potentially transition a stream's state.
@@ -173,6 +183,16 @@ impl Counts {
173183 self . max_send_streams
174184 }
175185
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+
176196 /// Returns the maximum number of streams that can be initiated by the
177197 /// remote peer.
178198 pub ( crate ) fn max_recv_streams ( & self ) -> usize {
@@ -197,6 +217,12 @@ impl Counts {
197217 assert ! ( self . num_reset_streams > 0 ) ;
198218 self . num_reset_streams -= 1 ;
199219 }
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+ }
200226}
201227
202228impl Drop for Counts {
0 commit comments