@@ -178,18 +178,6 @@ impl SystemExecutor for MultiThreadedExecutor {
178
178
self . rebuild_active_access ( ) ;
179
179
}
180
180
}
181
-
182
- // SAFETY: all systems have completed
183
- let world = unsafe { & mut * world. get ( ) } ;
184
- apply_system_buffers ( & mut self . unapplied_systems , systems, world) ;
185
-
186
- debug_assert ! ( self . ready_systems. is_clear( ) ) ;
187
- debug_assert ! ( self . running_systems. is_clear( ) ) ;
188
- debug_assert ! ( self . unapplied_systems. is_clear( ) ) ;
189
- self . active_access . clear ( ) ;
190
- self . evaluated_sets . clear ( ) ;
191
- self . skipped_systems . clear ( ) ;
192
- self . completed_systems . clear ( ) ;
193
181
} ;
194
182
195
183
#[ cfg( feature = "trace" ) ]
@@ -198,6 +186,19 @@ impl SystemExecutor for MultiThreadedExecutor {
198
186
let executor = executor. instrument ( executor_span) ;
199
187
scope. spawn ( executor) ;
200
188
} ) ;
189
+
190
+ // Do one final apply buffers after all systems have completed
191
+ // SAFETY: all systems have completed, and so no outstanding accesses remain
192
+ let world = unsafe { & mut * world. get ( ) } ;
193
+ apply_system_buffers ( & mut self . unapplied_systems , systems, world) ;
194
+
195
+ debug_assert ! ( self . ready_systems. is_clear( ) ) ;
196
+ debug_assert ! ( self . running_systems. is_clear( ) ) ;
197
+ debug_assert ! ( self . unapplied_systems. is_clear( ) ) ;
198
+ self . active_access . clear ( ) ;
199
+ self . evaluated_sets . clear ( ) ;
200
+ self . skipped_systems . clear ( ) ;
201
+ self . completed_systems . clear ( ) ;
201
202
}
202
203
}
203
204
0 commit comments