387 else Future.map (fn after_load => (after_load (); fn () => ())) future; |
387 else Future.map (fn after_load => (after_load (); fn () => ())) future; |
388 in Symtab.update (name, future') tab end; |
388 in Symtab.update (name, future') tab end; |
389 |
389 |
390 val futures = fold fork tasks Symtab.empty; |
390 val futures = fold fork tasks Symtab.empty; |
391 |
391 |
392 val exns = tasks |> maps (fn (name, _) => |
392 val failed = tasks |> maps (fn (name, _) => |
393 let |
393 let |
394 val after_load = Future.join (the (Symtab.lookup futures name)); |
394 val after_load = Future.join (the (Symtab.lookup futures name)); |
395 val _ = join_thy name; |
395 val _ = join_thy name; |
396 val _ = after_load (); |
396 val _ = after_load (); |
397 in [] end handle exn => (kill_thy name; [exn])); |
397 in [] end handle exn => [(name, exn)]) |> rev; |
398 |
398 |
399 in ignore (Exn.release_all (map Exn.Exn (rev exns))) end) (); |
399 val _ = List.app (kill_thy o #1) failed; |
|
400 val _ = Exn.release_all (map (Exn.Exn o #2) failed); |
|
401 in () end) (); |
400 |
402 |
401 fun schedule_seq tasks = |
403 fun schedule_seq tasks = |
402 Graph.topological_order tasks |
404 Graph.topological_order tasks |
403 |> List.app (fn name => |
405 |> List.app (fn name => |
404 (case Graph.get_node tasks name of |
406 (case Graph.get_node tasks name of |