File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -144,24 +144,25 @@ impl Notifier {
144144 /// Wait for all [`Waiter`]s to drop.
145145 pub async fn wait_all_exit ( & self ) -> Result < ( ) , Elapsed > {
146146 //debug_assert!(self.shared.is_shutdown());
147- if self . waiters ( ) == 0 {
148- return Ok ( ( ) ) ;
149- }
150- let wait = self . wait ( ) ;
151- if self . waiters ( ) == 0 {
152- return Ok ( ( ) ) ;
153- }
154- wait. await
155- }
156-
157- async fn wait ( & self ) -> Result < ( ) , Elapsed > {
158147 if let Some ( tm) = self . wait_time {
159- timeout ( tm, self . shared . notify_exit . notified ( ) ) . await
148+ timeout ( tm, self . wait ( ) ) . await
160149 } else {
161- self . shared . notify_exit . notified ( ) . await ;
150+ self . wait ( ) . await ;
162151 Ok ( ( ) )
163152 }
164153 }
154+
155+ async fn wait ( & self ) {
156+ while self . waiters ( ) > 0 {
157+ let notified = self . shared . notify_exit . notified ( ) ;
158+ if self . waiters ( ) == 0 {
159+ return ;
160+ }
161+ notified. await ;
162+ // Some waiters could have been created in the meantime
163+ // by calling `subscribe`, loop again
164+ }
165+ }
165166}
166167
167168impl Drop for Notifier {
You can’t perform that action at this time.
0 commit comments