- while ecx.schedule()? {
- assert!(ecx.step()?, "Bug: a terminated thread was scheduled for execution.");
- ecx.process_diagnostics();
+ loop {
+ let info = ecx.preprocess_diagnostics();
+ match ecx.schedule()? {
+ SchedulingAction::ExecuteStep => {
+ assert!(ecx.step()?, "a terminated thread was scheduled for execution");
+ }
+ SchedulingAction::ExecuteTimeoutCallback => {
+ assert!(ecx.machine.communicate,
+ "scheduler callbacks require disabled isolation, but the code \
+ that created the callback did not check it");
+ ecx.run_timeout_callback()?;
+ }
+ SchedulingAction::ExecuteDtors => {
+ // This will either enable the thread again (so we go back
+ // to `ExecuteStep`), or determine that this thread is done
+ // for good.
+ ecx.schedule_next_tls_dtor_for_active_thread()?;
+ }
+ SchedulingAction::Stop => {
+ break;
+ }
+ }
+ ecx.process_diagnostics(info);