@@ -178,19 +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 ( & self . unapplied_systems , systems, world) ;
185
- self . unapplied_systems . clear ( ) ;
186
- debug_assert ! ( self . unapplied_systems. is_clear( ) ) ;
187
-
188
- debug_assert ! ( self . ready_systems. is_clear( ) ) ;
189
- debug_assert ! ( self . running_systems. is_clear( ) ) ;
190
- self . active_access . clear ( ) ;
191
- self . evaluated_sets . clear ( ) ;
192
- self . skipped_systems . clear ( ) ;
193
- self . completed_systems . clear ( ) ;
194
181
} ;
195
182
196
183
#[ cfg( feature = "trace" ) ]
@@ -199,6 +186,20 @@ impl SystemExecutor for MultiThreadedExecutor {
199
186
let executor = executor. instrument ( executor_span) ;
200
187
scope. spawn ( executor) ;
201
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 ( & self . unapplied_systems , systems, world) ;
194
+ self . unapplied_systems . clear ( ) ;
195
+ debug_assert ! ( self . unapplied_systems. is_clear( ) ) ;
196
+
197
+ debug_assert ! ( self . ready_systems. is_clear( ) ) ;
198
+ debug_assert ! ( self . running_systems. is_clear( ) ) ;
199
+ self . active_access . clear ( ) ;
200
+ self . evaluated_sets . clear ( ) ;
201
+ self . skipped_systems . clear ( ) ;
202
+ self . completed_systems . clear ( ) ;
202
203
}
203
204
}
204
205
0 commit comments