176 preplay_data := Canonical_Label_Tab.update (l, fold (AList.update (op =)) meths_outcomes []) |
176 preplay_data := Canonical_Label_Tab.update (l, fold (AList.update (op =)) meths_outcomes []) |
177 (!preplay_data) |
177 (!preplay_data) |
178 end |
178 end |
179 | set_preplay_outcomes_of_isar_step _ _ _ _ _ _ = () |
179 | set_preplay_outcomes_of_isar_step _ _ _ _ _ _ = () |
180 |
180 |
181 fun peek_at_outcome outcome = if Lazy.is_finished outcome then Lazy.force outcome else Not_Played |
181 fun peek_at_outcome outcome = |
|
182 if Lazy.is_finished outcome then Lazy.force outcome else Play_Timed_Out Time.zeroTime |
182 |
183 |
183 fun get_best_method_outcome force = |
184 fun get_best_method_outcome force = |
184 tap (List.app (K () o Lazy.future Future.default_params o snd)) (* optional parallelism *) |
185 tap (List.app (K () o Lazy.future Future.default_params o snd)) (* optional parallelism *) |
185 #> map (apsnd force) |
186 #> map (apsnd force) |
186 #> sort (play_outcome_ord o pairself snd) |
187 #> sort (play_outcome_ord o pairself snd) |
193 if forall (not o Lazy.is_finished o snd) meths_outcomes then |
194 if forall (not o Lazy.is_finished o snd) meths_outcomes then |
194 (case Lazy.force outcome1 of |
195 (case Lazy.force outcome1 of |
195 outcome as Played _ => outcome |
196 outcome as Played _ => outcome |
196 | _ => snd (get_best_method_outcome Lazy.force meths_outcomes)) |
197 | _ => snd (get_best_method_outcome Lazy.force meths_outcomes)) |
197 else |
198 else |
198 (case get_best_method_outcome peek_at_outcome meths_outcomes of |
199 let val outcome = snd (get_best_method_outcome peek_at_outcome meths_outcomes) in |
199 (_, Not_Played) => snd (get_best_method_outcome Lazy.force meths_outcomes) |
200 if outcome = Play_Timed_Out Time.zeroTime then |
200 | (_, outcome) => outcome) |
201 snd (get_best_method_outcome Lazy.force meths_outcomes) |
|
202 else |
|
203 outcome |
|
204 end |
201 end |
205 end |
202 |
206 |
203 fun preplay_outcome_of_isar_step_for_method preplay_data l = |
207 fun preplay_outcome_of_isar_step_for_method preplay_data l = |
204 AList.lookup (op =) (the (Canonical_Label_Tab.lookup preplay_data l)) |
208 AList.lookup (op =) (the (Canonical_Label_Tab.lookup preplay_data l)) |
205 #> the_default (Lazy.value Not_Played) |
209 #> the_default (Lazy.value (Play_Timed_Out Time.zeroTime)) |
206 |
210 |
207 fun fastest_method_of_isar_step preplay_data = |
211 fun fastest_method_of_isar_step preplay_data = |
208 the o Canonical_Label_Tab.lookup preplay_data |
212 the o Canonical_Label_Tab.lookup preplay_data |
209 #> get_best_method_outcome Lazy.force |
213 #> get_best_method_outcome Lazy.force |
210 #> fst |
214 #> fst |