src/Pure/Thy/thy_info.ML
changeset 38143 3342c68d8782
parent 38142 c202426474c3
child 38145 675827e61eb9
equal deleted inserted replaced
38142:c202426474c3 38143:3342c68d8782
   172     | Finished thy => Symtab.update (name, thy) tab))) |> ignore;
   172     | Finished thy => Symtab.update (name, thy) tab))) |> ignore;
   173 
   173 
   174 fun schedule_futures task_graph = uninterruptible (fn _ => fn () =>
   174 fun schedule_futures task_graph = uninterruptible (fn _ => fn () =>
   175   let
   175   let
   176     val tasks = Graph.topological_order task_graph;
   176     val tasks = Graph.topological_order task_graph;
   177     val par_proofs = ! parallel_proofs >= 1;
       
   178 
       
   179     val futures = (tasks, Symtab.empty) |-> fold (fn name => fn tab =>
   177     val futures = (tasks, Symtab.empty) |-> fold (fn name => fn tab =>
   180       (case Graph.get_node task_graph name of
   178       (case Graph.get_node task_graph name of
   181         Task (parents, body) =>
   179         Task (parents, body) =>
   182           let
   180           let
   183             val get = the o Symtab.lookup tab;
   181             val get = the o Symtab.lookup tab;
   187             val future = Future.fork_deps (map #1 deps) (fn () =>
   185             val future = Future.fork_deps (map #1 deps) (fn () =>
   188               (case map_filter failed deps of
   186               (case map_filter failed deps of
   189                 [] => body (map (#1 o Future.join o get) parents)
   187                 [] => body (map (#1 o Future.join o get) parents)
   190               | bad => error (loader_msg
   188               | bad => error (loader_msg
   191                   ("failed to load " ^ quote name ^ " (unresolved " ^ commas_quote bad ^ ")") [])));
   189                   ("failed to load " ^ quote name ^ " (unresolved " ^ commas_quote bad ^ ")") [])));
   192             val future' =
   190           in Symtab.update (name, future) tab end
   193               if par_proofs then future
       
   194               else Future.map (fn (thy, after_load) => (after_load (); (thy, I))) future;
       
   195           in Symtab.update (name, future') tab end
       
   196       | Finished thy => Symtab.update (name, Future.value (thy, I)) tab));
   191       | Finished thy => Symtab.update (name, Future.value (thy, I)) tab));
   197 
       
   198     val _ =
   192     val _ =
   199       tasks |> maps (fn name =>
   193       tasks |> maps (fn name =>
   200         let
   194         let
   201           val (thy, after_load) = Future.join (the (Symtab.lookup futures name));
   195           val (thy, after_load) = Future.join (the (Symtab.lookup futures name));
   202           val _ = PureThy.join_proofs thy;
   196           val _ = PureThy.join_proofs thy;