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 {
144
144
/// Wait for all [`Waiter`]s to drop.
145
145
pub async fn wait_all_exit ( & self ) -> Result < ( ) , Elapsed > {
146
146
//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 > {
158
147
if let Some ( tm) = self . wait_time {
159
- timeout ( tm, self . shared . notify_exit . notified ( ) ) . await
148
+ timeout ( tm, self . wait ( ) ) . await
160
149
} else {
161
- self . shared . notify_exit . notified ( ) . await ;
150
+ self . wait ( ) . await ;
162
151
Ok ( ( ) )
163
152
}
164
153
}
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
+ }
165
166
}
166
167
167
168
impl Drop for Notifier {
You can’t perform that action at this time.
0 commit comments