src/Pure/PIDE/command.ML
author wenzelm
Mon Feb 17 11:14:26 2014 +0100 (2014-02-17 ago)
changeset 55526 39708e59f4b0
parent 55429 4a50f9e70dc1
child 55708 f4b114070675
permissions -rw-r--r--
more markup;
wenzelm@47336
     1
(*  Title:      Pure/PIDE/command.ML
wenzelm@47336
     2
    Author:     Makarius
wenzelm@47336
     3
wenzelm@52534
     4
Prover command execution: read -- eval -- print.
wenzelm@47336
     5
*)
wenzelm@47336
     6
wenzelm@47336
     7
signature COMMAND =
wenzelm@47336
     8
sig
wenzelm@54526
     9
  type blob = (string * string option) Exn.result
wenzelm@54526
    10
  val read_file: Path.T -> Position.T -> Path.T -> Token.file
wenzelm@54526
    11
  val read: (unit -> theory) -> Path.T -> blob list -> Token.T list -> Toplevel.transition
wenzelm@52600
    12
  type eval
wenzelm@52607
    13
  val eval_eq: eval * eval -> bool
wenzelm@52784
    14
  val eval_running: eval -> bool
wenzelm@52772
    15
  val eval_finished: eval -> bool
wenzelm@52536
    16
  val eval_result_state: eval -> Toplevel.state
wenzelm@54526
    17
  val eval: (unit -> theory) -> Path.T -> blob list -> Token.T list -> eval -> eval
wenzelm@52600
    18
  type print
wenzelm@52850
    19
  val print: bool -> (string * string list) list -> string ->
wenzelm@52850
    20
    eval -> print list -> print list option
wenzelm@52526
    21
  type print_fn = Toplevel.transition -> Toplevel.state -> unit
wenzelm@52953
    22
  type print_function =
wenzelm@52953
    23
    {command_name: string, args: string list} ->
wenzelm@52953
    24
      {delay: Time.time option, pri: int, persistent: bool, strict: bool, print_fn: print_fn} option
wenzelm@52953
    25
  val print_function: string -> print_function -> unit
wenzelm@52571
    26
  val no_print_function: string -> unit
wenzelm@52600
    27
  type exec = eval * print list
wenzelm@52600
    28
  val no_exec: exec
wenzelm@52600
    29
  val exec_ids: exec option -> Document_ID.exec list
wenzelm@52606
    30
  val exec: Document_ID.execution -> exec -> unit
wenzelm@47336
    31
end;
wenzelm@47336
    32
wenzelm@47336
    33
structure Command: COMMAND =
wenzelm@47336
    34
struct
wenzelm@47336
    35
wenzelm@52775
    36
(** memo results **)
wenzelm@47341
    37
wenzelm@47341
    38
datatype 'a expr =
wenzelm@52596
    39
  Expr of Document_ID.exec * (unit -> 'a) |
wenzelm@47341
    40
  Result of 'a Exn.result;
wenzelm@47341
    41
wenzelm@47341
    42
abstype 'a memo = Memo of 'a expr Synchronized.var
wenzelm@47341
    43
with
wenzelm@47341
    44
wenzelm@52596
    45
fun memo exec_id e = Memo (Synchronized.var "Command.memo" (Expr (exec_id, e)));
wenzelm@47341
    46
fun memo_value a = Memo (Synchronized.var "Command.memo" (Result (Exn.Res a)));
wenzelm@47341
    47
wenzelm@47342
    48
fun memo_result (Memo v) =
wenzelm@47342
    49
  (case Synchronized.value v of
wenzelm@52607
    50
    Expr (exec_id, _) => error ("Unfinished execution result: " ^ Document_ID.print exec_id)
wenzelm@52607
    51
  | Result res => Exn.release res);
wenzelm@47341
    52
wenzelm@52656
    53
fun memo_finished (Memo v) =
wenzelm@52785
    54
  (case Synchronized.value v of Expr _ => false | Result _ => true);
wenzelm@52656
    55
wenzelm@52607
    56
fun memo_exec execution_id (Memo v) =
wenzelm@52774
    57
  Synchronized.timed_access v (K (SOME Time.zeroTime))
wenzelm@52609
    58
    (fn expr =>
wenzelm@52609
    59
      (case expr of
wenzelm@52775
    60
        Expr (exec_id, body) =>
wenzelm@52609
    61
          uninterruptible (fn restore_attributes => fn () =>
wenzelm@54637
    62
            let val group = Future.worker_subgroup () in
wenzelm@54637
    63
              if Execution.running execution_id exec_id [group] then
wenzelm@54637
    64
                let
wenzelm@54637
    65
                  val res =
wenzelm@54637
    66
                    (body
wenzelm@54637
    67
                      |> restore_attributes
wenzelm@54649
    68
                      |> Future.task_context "Command.memo_exec" group
wenzelm@54637
    69
                      |> Exn.interruptible_capture) ();
wenzelm@54637
    70
                in SOME ((), Result res) end
wenzelm@54637
    71
              else SOME ((), expr)
wenzelm@54637
    72
            end) ()
wenzelm@52775
    73
      | Result _ => SOME ((), expr)))
wenzelm@52775
    74
  |> (fn NONE => error "Conflicting command execution" | _ => ());
wenzelm@52596
    75
wenzelm@52607
    76
fun memo_fork params execution_id (Memo v) =
wenzelm@52596
    77
  (case Synchronized.value v of
wenzelm@52596
    78
    Result _ => ()
wenzelm@52607
    79
  | _ => ignore ((singleton o Future.forks) params (fn () => memo_exec execution_id (Memo v))));
wenzelm@52526
    80
wenzelm@47341
    81
end;
wenzelm@47341
    82
wenzelm@47341
    83
wenzelm@52607
    84
wenzelm@52536
    85
(** main phases of execution **)
wenzelm@52536
    86
wenzelm@52510
    87
(* read *)
wenzelm@52509
    88
wenzelm@54526
    89
type blob = (string * string option) Exn.result;  (*file node name, digest or text*)
wenzelm@54519
    90
wenzelm@54526
    91
fun read_file master_dir pos src_path =
wenzelm@54526
    92
  let
wenzelm@54526
    93
    val full_path = File.check_file (File.full_path master_dir src_path);
wenzelm@54526
    94
    val _ = Position.report pos (Markup.path (Path.implode full_path));
wenzelm@54526
    95
  in {src_path = src_path, text = File.read full_path, pos = Path.position full_path} end;
wenzelm@54526
    96
wenzelm@54526
    97
fun resolve_files master_dir blobs toks =
wenzelm@54519
    98
  (case Thy_Syntax.parse_spans toks of
wenzelm@54519
    99
    [span] => span
wenzelm@54523
   100
      |> Thy_Syntax.resolve_files (fn cmd => fn (path, pos) =>
wenzelm@54523
   101
        let
wenzelm@54526
   102
          fun make_file src_path (Exn.Res (_, NONE)) =
wenzelm@54526
   103
                Exn.interruptible_capture (fn () => read_file master_dir pos src_path) ()
wenzelm@54526
   104
            | make_file src_path (Exn.Res (file, SOME text)) =
wenzelm@55429
   105
                let
wenzelm@55429
   106
                  val _ = Position.report pos (Markup.path file);
wenzelm@55429
   107
                  val file_pos =
wenzelm@55429
   108
                    Position.file file (*sic!*) |>
wenzelm@55429
   109
                    (case Position.get_id (Position.thread_data ()) of
wenzelm@55429
   110
                      NONE => I
wenzelm@55429
   111
                    | SOME exec_id => Position.put_id exec_id);
wenzelm@55429
   112
                in Exn.Res {src_path = src_path, text = text, pos = file_pos} end
wenzelm@54523
   113
            | make_file _ (Exn.Exn e) = Exn.Exn e;
wenzelm@54523
   114
wenzelm@54523
   115
          val src_paths = Keyword.command_files cmd path;
wenzelm@54523
   116
        in
wenzelm@54527
   117
          if null blobs then
wenzelm@54527
   118
            map2 make_file src_paths (map (K (Exn.Res ("", NONE))) src_paths)
wenzelm@54527
   119
          else if length src_paths = length blobs then
wenzelm@54527
   120
            map2 make_file src_paths blobs
wenzelm@54527
   121
          else error ("Misalignment of inlined files" ^ Position.here pos)
wenzelm@54523
   122
        end)
wenzelm@54519
   123
      |> Thy_Syntax.span_content
wenzelm@54519
   124
  | _ => toks);
wenzelm@54519
   125
wenzelm@54526
   126
fun read init master_dir blobs span =
wenzelm@52510
   127
  let
wenzelm@52510
   128
    val outer_syntax = #2 (Outer_Syntax.get_syntax ());
wenzelm@52510
   129
    val command_reports = Outer_Syntax.command_reports outer_syntax;
wenzelm@52509
   130
wenzelm@52534
   131
    val proper_range =
wenzelm@52534
   132
      Position.set_range (Token.position_range_of (#1 (take_suffix Token.is_improper span)));
wenzelm@52510
   133
    val pos =
wenzelm@52510
   134
      (case find_first Token.is_command span of
wenzelm@52510
   135
        SOME tok => Token.position_of tok
wenzelm@52510
   136
      | NONE => proper_range);
wenzelm@52509
   137
wenzelm@52510
   138
    val (is_malformed, token_reports) = Thy_Syntax.reports_of_tokens span;
wenzelm@52510
   139
    val _ = Position.reports_text (token_reports @ maps command_reports span);
wenzelm@52510
   140
  in
wenzelm@52510
   141
    if is_malformed then Toplevel.malformed pos "Malformed command syntax"
wenzelm@52510
   142
    else
wenzelm@54526
   143
      (case Outer_Syntax.read_spans outer_syntax (resolve_files master_dir blobs span) of
wenzelm@52510
   144
        [tr] =>
wenzelm@52510
   145
          if Keyword.is_control (Toplevel.name_of tr) then
wenzelm@52510
   146
            Toplevel.malformed pos "Illegal control command"
wenzelm@52534
   147
          else Toplevel.modify_init init tr
wenzelm@52534
   148
      | [] => Toplevel.ignored (Position.set_range (Token.position_range_of span))
wenzelm@52510
   149
      | _ => Toplevel.malformed proper_range "Exactly one command expected")
wenzelm@52510
   150
      handle ERROR msg => Toplevel.malformed proper_range msg
wenzelm@52510
   151
  end;
wenzelm@52509
   152
wenzelm@52509
   153
wenzelm@52509
   154
(* eval *)
wenzelm@47336
   155
wenzelm@52600
   156
type eval_state =
wenzelm@52600
   157
  {failed: bool, malformed: bool, command: Toplevel.transition, state: Toplevel.state};
wenzelm@52600
   158
val init_eval_state =
wenzelm@52600
   159
  {failed = false, malformed = false, command = Toplevel.empty, state = Toplevel.toplevel};
wenzelm@52600
   160
wenzelm@52600
   161
datatype eval = Eval of {exec_id: Document_ID.exec, eval_process: eval_state memo};
wenzelm@52600
   162
wenzelm@52607
   163
fun eval_eq (Eval {exec_id, ...}, Eval {exec_id = exec_id', ...}) = exec_id = exec_id';
wenzelm@52607
   164
wenzelm@52784
   165
fun eval_running (Eval {exec_id, ...}) = Execution.is_running_exec exec_id;
wenzelm@52772
   166
fun eval_finished (Eval {eval_process, ...}) = memo_finished eval_process;
wenzelm@52772
   167
wenzelm@52600
   168
fun eval_result (Eval {eval_process, ...}) = memo_result eval_process;
wenzelm@52600
   169
val eval_result_state = #state o eval_result;
wenzelm@52600
   170
wenzelm@47336
   171
local
wenzelm@47336
   172
wenzelm@47336
   173
fun run int tr st =
wenzelm@53189
   174
  if Goal.future_enabled 1 andalso Keyword.is_diag (Toplevel.name_of tr) then
wenzelm@53192
   175
    (Execution.fork {name = "Toplevel.diag", pos = Toplevel.pos_of tr, pri = ~1}
wenzelm@51605
   176
      (fn () => Toplevel.command_exception int tr st); ([], SOME st))
wenzelm@51284
   177
  else Toplevel.command_errors int tr st;
wenzelm@47336
   178
wenzelm@52510
   179
fun check_cmts span tr st' =
wenzelm@52510
   180
  Toplevel.setmp_thread_position tr
wenzelm@52510
   181
    (fn () =>
wenzelm@52510
   182
      Outer_Syntax.side_comments span |> maps (fn cmt =>
wenzelm@52510
   183
        (Thy_Output.check_text (Token.source_position_of cmt) st'; [])
wenzelm@52619
   184
          handle exn =>
wenzelm@52619
   185
            if Exn.is_interrupt exn then reraise exn
wenzelm@52619
   186
            else ML_Compiler.exn_messages_ids exn)) ();
wenzelm@52510
   187
wenzelm@54678
   188
fun report tr m =
wenzelm@54678
   189
  Toplevel.setmp_thread_position tr (fn () => Output.report (Markup.markup_only m)) ();
wenzelm@54678
   190
wenzelm@54678
   191
fun status tr m =
wenzelm@54678
   192
  Toplevel.setmp_thread_position tr (fn () => Output.status (Markup.markup_only m)) ();
wenzelm@54678
   193
wenzelm@47336
   194
fun proof_status tr st =
wenzelm@47336
   195
  (case try Toplevel.proof_of st of
wenzelm@54678
   196
    SOME prf => status tr (Proof.status_markup prf)
wenzelm@47336
   197
  | NONE => ());
wenzelm@47336
   198
wenzelm@52534
   199
fun eval_state span tr ({malformed, state = st, ...}: eval_state) =
wenzelm@52509
   200
  if malformed then
wenzelm@52526
   201
    {failed = true, malformed = malformed, command = tr, state = Toplevel.toplevel}
wenzelm@48772
   202
  else
wenzelm@48772
   203
    let
wenzelm@48772
   204
      val malformed' = Toplevel.is_malformed tr;
wenzelm@48772
   205
      val is_init = Toplevel.is_init tr;
wenzelm@48772
   206
      val is_proof = Keyword.is_proof (Toplevel.name_of tr);
wenzelm@47336
   207
wenzelm@48772
   208
      val _ = Multithreading.interrupted ();
wenzelm@54678
   209
      val _ = status tr Markup.running;
wenzelm@48918
   210
      val (errs1, result) = run (is_init orelse is_proof) (Toplevel.set_print false tr) st;
wenzelm@52509
   211
      val errs2 = (case result of NONE => [] | SOME st' => check_cmts span tr st');
wenzelm@48918
   212
      val errs = errs1 @ errs2;
wenzelm@50914
   213
      val _ = List.app (Future.error_msg (Toplevel.pos_of tr)) errs;
wenzelm@48772
   214
    in
wenzelm@48772
   215
      (case result of
wenzelm@48772
   216
        NONE =>
wenzelm@48772
   217
          let
wenzelm@54678
   218
            val _ = status tr Markup.failed;
wenzelm@54678
   219
            val _ = status tr Markup.finished;
wenzelm@54678
   220
            val _ = if null errs then (report tr Markup.bad; Exn.interrupt ()) else ();
wenzelm@52526
   221
          in {failed = true, malformed = malformed', command = tr, state = st} end
wenzelm@48772
   222
      | SOME st' =>
wenzelm@48772
   223
          let
wenzelm@48772
   224
            val _ = proof_status tr st';
wenzelm@54678
   225
            val _ = status tr Markup.finished;
wenzelm@52526
   226
          in {failed = false, malformed = malformed', command = tr, state = st'} end)
wenzelm@48772
   227
    end;
wenzelm@47336
   228
wenzelm@52534
   229
in
wenzelm@52534
   230
wenzelm@54526
   231
fun eval init master_dir blobs span eval0 =
wenzelm@52534
   232
  let
wenzelm@52534
   233
    val exec_id = Document_ID.make ();
wenzelm@52534
   234
    fun process () =
wenzelm@52534
   235
      let
wenzelm@52534
   236
        val tr =
wenzelm@52534
   237
          Position.setmp_thread_data (Position.id_only (Document_ID.print exec_id))
wenzelm@54526
   238
            (fn () => read init master_dir blobs span |> Toplevel.exec_id exec_id) ();
wenzelm@52534
   239
      in eval_state span tr (eval_result eval0) end;
wenzelm@52600
   240
  in Eval {exec_id = exec_id, eval_process = memo exec_id process} end;
wenzelm@52534
   241
wenzelm@47336
   242
end;
wenzelm@47336
   243
wenzelm@52509
   244
wenzelm@52509
   245
(* print *)
wenzelm@52509
   246
wenzelm@52600
   247
datatype print = Print of
wenzelm@52850
   248
 {name: string, args: string list, delay: Time.time option, pri: int, persistent: bool,
wenzelm@52600
   249
  exec_id: Document_ID.exec, print_process: unit memo};
wenzelm@52600
   250
wenzelm@52526
   251
type print_fn = Toplevel.transition -> Toplevel.state -> unit;
wenzelm@52515
   252
wenzelm@52647
   253
type print_function =
wenzelm@52850
   254
  {command_name: string, args: string list} ->
wenzelm@52953
   255
    {delay: Time.time option, pri: int, persistent: bool, strict: bool, print_fn: print_fn} option;
wenzelm@52647
   256
wenzelm@52511
   257
local
wenzelm@52511
   258
wenzelm@52647
   259
val print_functions =
wenzelm@52647
   260
  Synchronized.var "Command.print_functions" ([]: (string * print_function) list);
wenzelm@52511
   261
wenzelm@52570
   262
fun print_error tr e =
wenzelm@53709
   263
  (Toplevel.setmp_thread_position tr o Toplevel.controlled_execution) e ()
wenzelm@52619
   264
    handle exn =>
wenzelm@52619
   265
      if Exn.is_interrupt exn then reraise exn
wenzelm@52619
   266
      else List.app (Future.error_msg (Toplevel.pos_of tr)) (ML_Compiler.exn_messages_ids exn);
wenzelm@52516
   267
wenzelm@52607
   268
fun print_eq (Print {exec_id, ...}, Print {exec_id = exec_id', ...}) = exec_id = exec_id';
wenzelm@52607
   269
wenzelm@52775
   270
fun print_finished (Print {print_process, ...}) = memo_finished print_process;
wenzelm@52656
   271
wenzelm@52600
   272
fun print_persistent (Print {persistent, ...}) = persistent;
wenzelm@52596
   273
wenzelm@52853
   274
val overlay_ord = prod_ord string_ord (list_ord string_ord);
wenzelm@52853
   275
wenzelm@52511
   276
in
wenzelm@52509
   277
wenzelm@52850
   278
fun print command_visible command_overlays command_name eval old_prints =
wenzelm@52570
   279
  let
wenzelm@52850
   280
    val print_functions = Synchronized.value print_functions;
wenzelm@52850
   281
wenzelm@52999
   282
    fun make_print name args {delay, pri, persistent, strict, print_fn} =
wenzelm@52999
   283
      let
wenzelm@52999
   284
        val exec_id = Document_ID.make ();
wenzelm@52999
   285
        fun process () =
wenzelm@52999
   286
          let
wenzelm@52999
   287
            val {failed, command, state = st', ...} = eval_result eval;
wenzelm@52999
   288
            val tr = Toplevel.exec_id exec_id command;
wenzelm@52999
   289
          in
wenzelm@52999
   290
            if failed andalso strict then ()
wenzelm@52999
   291
            else print_error tr (fn () => print_fn tr st')
wenzelm@52999
   292
          end;
wenzelm@52999
   293
      in
wenzelm@52999
   294
        Print {
wenzelm@52999
   295
          name = name, args = args, delay = delay, pri = pri, persistent = persistent,
wenzelm@52999
   296
          exec_id = exec_id, print_process = memo exec_id process}
wenzelm@52999
   297
      end;
wenzelm@52999
   298
wenzelm@52999
   299
    fun bad_print name args exn =
wenzelm@52999
   300
      make_print name args {delay = NONE, pri = 0, persistent = false,
wenzelm@52999
   301
        strict = false, print_fn = fn _ => fn _ => reraise exn};
wenzelm@52999
   302
wenzelm@52850
   303
    fun new_print name args get_pr =
wenzelm@52570
   304
      let
wenzelm@52850
   305
        val params = {command_name = command_name, args = args};
wenzelm@52570
   306
      in
wenzelm@53709
   307
        (case Exn.capture (Toplevel.controlled_execution get_pr) params of
wenzelm@52570
   308
          Exn.Res NONE => NONE
wenzelm@52999
   309
        | Exn.Res (SOME pr) => SOME (make_print name args pr)
wenzelm@52999
   310
        | Exn.Exn exn => SOME (bad_print name args exn))
wenzelm@52570
   311
      end;
wenzelm@52570
   312
wenzelm@52850
   313
    fun get_print (a, b) =
wenzelm@52850
   314
      (case find_first (fn Print {name, args, ...} => name = a andalso args = b) old_prints of
wenzelm@52850
   315
        NONE =>
wenzelm@52850
   316
          (case AList.lookup (op =) print_functions a of
wenzelm@52999
   317
            NONE => SOME (bad_print a b (ERROR ("Missing print function " ^ quote a)))
wenzelm@52850
   318
          | SOME get_pr => new_print a b get_pr)
wenzelm@52850
   319
      | some => some);
wenzelm@52850
   320
wenzelm@52570
   321
    val new_prints =
wenzelm@52570
   322
      if command_visible then
wenzelm@52853
   323
        fold (fn (a, _) => cons (a, [])) print_functions command_overlays
wenzelm@52853
   324
        |> sort_distinct overlay_ord
wenzelm@52850
   325
        |> map_filter get_print
wenzelm@52656
   326
      else filter (fn print => print_finished print andalso print_persistent print) old_prints;
wenzelm@52570
   327
  in
wenzelm@52600
   328
    if eq_list print_eq (old_prints, new_prints) then NONE else SOME new_prints
wenzelm@52570
   329
  end;
wenzelm@52511
   330
wenzelm@52647
   331
fun print_function name f =
wenzelm@52511
   332
  Synchronized.change print_functions (fn funs =>
wenzelm@52511
   333
   (if not (AList.defined (op =) funs name) then ()
wenzelm@52511
   334
    else warning ("Redefining command print function: " ^ quote name);
wenzelm@52647
   335
    AList.update (op =) (name, f) funs));
wenzelm@52511
   336
wenzelm@52571
   337
fun no_print_function name =
wenzelm@52571
   338
  Synchronized.change print_functions (filter_out (equal name o #1));
wenzelm@52571
   339
wenzelm@52511
   340
end;
wenzelm@52511
   341
wenzelm@52526
   342
val _ =
wenzelm@52647
   343
  print_function "print_state"
wenzelm@52850
   344
    (fn {command_name, ...} =>
wenzelm@53404
   345
      SOME {delay = NONE, pri = 1, persistent = false, strict = true,
wenzelm@52651
   346
        print_fn = fn tr => fn st' =>
wenzelm@52651
   347
          let
wenzelm@52651
   348
            val is_init = Keyword.is_theory_begin command_name;
wenzelm@52651
   349
            val is_proof = Keyword.is_proof command_name;
wenzelm@52651
   350
            val do_print =
wenzelm@52651
   351
              not is_init andalso
wenzelm@52651
   352
                (Toplevel.print_of tr orelse (is_proof andalso Toplevel.is_proof st'));
wenzelm@52651
   353
          in if do_print then Toplevel.print_state false st' else () end});
wenzelm@52509
   354
wenzelm@52532
   355
wenzelm@52600
   356
(* combined execution *)
wenzelm@52600
   357
wenzelm@52600
   358
type exec = eval * print list;
wenzelm@52600
   359
val no_exec: exec =
wenzelm@52600
   360
  (Eval {exec_id = Document_ID.none, eval_process = memo_value init_eval_state}, []);
wenzelm@52532
   361
wenzelm@52600
   362
fun exec_ids NONE = []
wenzelm@52600
   363
  | exec_ids (SOME (Eval {exec_id, ...}, prints)) =
wenzelm@52600
   364
      exec_id :: map (fn Print {exec_id, ...} => exec_id) prints;
wenzelm@52600
   365
wenzelm@52600
   366
local
wenzelm@52600
   367
wenzelm@52651
   368
fun run_print execution_id (Print {name, delay, pri, print_process, ...}) =
wenzelm@53976
   369
  if Multithreading.enabled () orelse pri <= 0 then
wenzelm@52651
   370
    let
wenzelm@52651
   371
      val group = Future.worker_subgroup ();
wenzelm@52651
   372
      fun fork () =
wenzelm@52651
   373
        memo_fork {name = name, group = SOME group, deps = [], pri = pri, interrupts = true}
wenzelm@52651
   374
          execution_id print_process;
wenzelm@52651
   375
    in
wenzelm@52762
   376
      (case delay of
wenzelm@52762
   377
        NONE => fork ()
wenzelm@52762
   378
      | SOME d => ignore (Event_Timer.request (Time.+ (Time.now (), d)) fork))
wenzelm@52651
   379
    end
wenzelm@52651
   380
  else memo_exec execution_id print_process;
wenzelm@52559
   381
wenzelm@52600
   382
in
wenzelm@52600
   383
wenzelm@52607
   384
fun exec execution_id (Eval {eval_process, ...}, prints) =
wenzelm@52607
   385
  (memo_exec execution_id eval_process; List.app (run_print execution_id) prints);
wenzelm@52532
   386
wenzelm@47336
   387
end;
wenzelm@47336
   388
wenzelm@52600
   389
end;
wenzelm@52600
   390