src/HOL/Tools/Sledgehammer/async_manager_legacy.ML
author wenzelm
Sat, 02 Apr 2016 23:29:05 +0200
changeset 62826 eb94e570c1a4
parent 61556 0d4ee4168e41
child 63692 1bc4bc2c9fd1
permissions -rw-r--r--
prefer infix operations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59471
ca459352d8c5 more explicit indication of Async_Manager_Legacy as Proof General legacy;
wenzelm
parents: 59468
diff changeset
     1
(*  Title:      HOL/Tools/Sledgehammer/async_manager_legacy.ML
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
     2
    Author:     Fabian Immler, TU Muenchen
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
     3
    Author:     Makarius
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
     4
    Author:     Jasmin Blanchette, TU Muenchen
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
     5
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
     6
Central manager for asynchronous diagnosis tool threads.
58894
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
     7
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
     8
Proof General legacy!
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
     9
*)
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    10
59471
ca459352d8c5 more explicit indication of Async_Manager_Legacy as Proof General legacy;
wenzelm
parents: 59468
diff changeset
    11
signature ASYNC_MANAGER_LEGACY =
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    12
sig
57556
6180d81be977 tuned whitespace (also in strings)
blanchet
parents: 56303
diff changeset
    13
  val thread : string -> Time.time -> Time.time -> string * string -> (unit -> bool * string) ->
6180d81be977 tuned whitespace (also in strings)
blanchet
parents: 56303
diff changeset
    14
    unit
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    15
  val has_running_threads : string -> bool
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    16
end;
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    17
59471
ca459352d8c5 more explicit indication of Async_Manager_Legacy as Proof General legacy;
wenzelm
parents: 59468
diff changeset
    18
structure Async_Manager_Legacy : ASYNC_MANAGER_LEGACY =
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    19
struct
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    20
58894
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    21
fun make_thread interrupts body =
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    22
  Thread.fork
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    23
    (fn () =>
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    24
      Runtime.debugging NONE body () handle exn =>
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    25
        if Exn.is_interrupt exn then ()
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    26
        else writeln ("## INTERNAL ERROR ##\n" ^ Runtime.exn_message exn),
61556
0d4ee4168e41 clarified modules;
wenzelm
parents: 61312
diff changeset
    27
      Standard_Thread.attributes
60764
b610ba36e02c more explicit thread identification;
wenzelm
parents: 59471
diff changeset
    28
        {name = "async_manager", stack_limit = NONE, interrupts = interrupts});
58894
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    29
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    30
fun implode_message (workers, work) =
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    31
  space_implode " " (Try.serial_commas "and" workers) ^ work
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    32
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    33
structure Thread_Heap = Heap
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    34
(
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    35
  type elem = Time.time * Thread.thread
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    36
  fun ord ((a, _), (b, _)) = Time.compare (a, b)
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    37
)
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    38
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    39
fun lookup_thread xs = AList.lookup Thread.equal xs
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    40
fun delete_thread xs = AList.delete Thread.equal xs
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    41
fun update_thread xs = AList.update Thread.equal xs
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    42
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    43
type state =
37585
c2ed8112ce57 multiplexing
blanchet
parents: 37584
diff changeset
    44
  {manager: Thread.thread option,
c2ed8112ce57 multiplexing
blanchet
parents: 37584
diff changeset
    45
   timeout_heap: Thread_Heap.T,
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    46
   active:
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    47
     (Thread.thread
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    48
      * (string * Time.time * Time.time * (string * string))) list,
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    49
   canceling:  (Thread.thread * (string * Time.time * (string * string))) list,
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    50
   messages: (bool * (string * (string * string))) list}
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    51
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    52
fun make_state manager timeout_heap active canceling messages : state =
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    53
  {manager = manager, timeout_heap = timeout_heap, active = active, canceling = canceling,
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    54
   messages = messages}
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    55
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    56
val global_state = Synchronized.var "async_manager" (make_state NONE Thread_Heap.empty [] [] [])
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    57
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    58
fun unregister (urgent, message) thread =
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    59
  Synchronized.change global_state
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    60
  (fn state as {manager, timeout_heap, active, canceling, messages} =>
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    61
    (case lookup_thread active thread of
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    62
      SOME (tool, _, _, desc as (worker, its_desc)) =>
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    63
        let
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    64
          val active' = delete_thread thread active
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    65
          val now = Time.now ()
37585
c2ed8112ce57 multiplexing
blanchet
parents: 37584
diff changeset
    66
          val canceling' = (thread, (tool, now, desc)) :: canceling
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    67
          val message' =
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    68
            (worker, its_desc ^ (if message = "" then "" else "\n" ^ message))
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    69
          val messages' = (urgent, (tool, message')) :: messages
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    70
        in make_state manager timeout_heap active' canceling' messages' end
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    71
    | NONE => state))
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    72
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    73
val min_wait_time = seconds 0.3
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    74
val max_wait_time = seconds 10.0
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    75
37585
c2ed8112ce57 multiplexing
blanchet
parents: 37584
diff changeset
    76
fun print_new_messages () =
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    77
  Synchronized.change_result global_state
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    78
      (fn {manager, timeout_heap, active, canceling, messages} =>
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    79
          messages
43055
6e0cb8044734 better merging of similar outputs
blanchet
parents: 43029
diff changeset
    80
          |> List.partition
6e0cb8044734 better merging of similar outputs
blanchet
parents: 43029
diff changeset
    81
                 (fn (urgent, _) =>
6e0cb8044734 better merging of similar outputs
blanchet
parents: 43029
diff changeset
    82
                     (null active andalso null canceling) orelse urgent)
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    83
          ||> make_state manager timeout_heap active canceling)
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    84
  |> map (fn (_, (tool, (worker, work))) => ((tool, work), worker))
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    85
  |> AList.group (op =)
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    86
  |> List.app (fn ((_, ""), _) => ()
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
    87
                | ((tool, work), workers) =>
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
    88
                  tool ^ ": " ^
47945
blanchet
parents: 47529
diff changeset
    89
                  implode_message (workers |> sort_distinct string_ord, work)
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    90
                  |> writeln)
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    91
39006
a02cb5717677 remove time information in output, since it's confusing anyway
blanchet
parents: 38990
diff changeset
    92
fun check_thread_manager () = Synchronized.change global_state
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
    93
  (fn state as {manager, timeout_heap, active, canceling, messages} =>
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    94
    if (case manager of SOME thread => Thread.isActive thread | NONE => false) then state
58894
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
    95
    else let val manager = SOME (make_thread false (fn () =>
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    96
      let
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    97
        fun time_limit timeout_heap =
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
    98
          (case try Thread_Heap.min timeout_heap of
62826
eb94e570c1a4 prefer infix operations;
wenzelm
parents: 61556
diff changeset
    99
            NONE => Time.now () + max_wait_time
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   100
          | SOME (time, _) => time)
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   101
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   102
        (*action: find threads whose timeout is reached, and interrupt canceling threads*)
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   103
        fun action {manager, timeout_heap, active, canceling, messages} =
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   104
          let val (timeout_threads, timeout_heap') =
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   105
            Thread_Heap.upto (Time.now (), Thread.self ()) timeout_heap
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   106
          in
37585
c2ed8112ce57 multiplexing
blanchet
parents: 37584
diff changeset
   107
            if null timeout_threads andalso null canceling then
c2ed8112ce57 multiplexing
blanchet
parents: 37584
diff changeset
   108
              NONE
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   109
            else
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   110
              let
61556
0d4ee4168e41 clarified modules;
wenzelm
parents: 61312
diff changeset
   111
                val _ = List.app (Standard_Thread.interrupt_unsynchronized o #1) canceling
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   112
                val canceling' = filter (Thread.isActive o #1) canceling
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   113
                val state' = make_state manager timeout_heap' active canceling' messages
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   114
              in SOME (map #2 timeout_threads, state') end
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   115
          end
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   116
      in
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   117
        while Synchronized.change_result global_state
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   118
          (fn state as {timeout_heap, active, canceling, messages, ...} =>
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   119
            if null active andalso null canceling andalso null messages
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   120
            then (false, make_state NONE timeout_heap active canceling messages)
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   121
            else (true, state))
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   122
        do
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   123
          (Synchronized.timed_access global_state
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   124
               (SOME o time_limit o #timeout_heap) action
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   125
           |> these
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   126
           |> List.app (unregister (false, "Timed out."));
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   127
           print_new_messages ();
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   128
           (* give threads some time to respond to interrupt *)
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   129
           OS.Process.sleep min_wait_time)
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   130
      end))
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   131
    in make_state manager timeout_heap active canceling messages end)
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   132
39006
a02cb5717677 remove time information in output, since it's confusing anyway
blanchet
parents: 38990
diff changeset
   133
fun register tool birth_time death_time desc thread =
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   134
 (Synchronized.change global_state
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   135
    (fn {manager, timeout_heap, active, canceling, messages} =>
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   136
      let
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   137
        val timeout_heap' = Thread_Heap.insert (death_time, thread) timeout_heap
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   138
        val active' = update_thread (thread, (tool, birth_time, death_time, desc)) active
61312
6d779a71086d further reduced dependency on legacy async thread manager
blanchet
parents: 60764
diff changeset
   139
        val state' = make_state manager timeout_heap' active' canceling messages
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   140
      in state' end);
39006
a02cb5717677 remove time information in output, since it's confusing anyway
blanchet
parents: 38990
diff changeset
   141
  check_thread_manager ())
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   142
52048
9003b293e775 tuned signature -- emphasize thread creation here;
wenzelm
parents: 48319
diff changeset
   143
fun thread tool birth_time death_time desc f =
58894
447972249785 clarified legacy code;
wenzelm
parents: 58843
diff changeset
   144
  (make_thread true
37584
2e289dc13615 factor out thread creation
blanchet
parents: 37583
diff changeset
   145
       (fn () =>
2e289dc13615 factor out thread creation
blanchet
parents: 37583
diff changeset
   146
           let
2e289dc13615 factor out thread creation
blanchet
parents: 37583
diff changeset
   147
             val self = Thread.self ()
39006
a02cb5717677 remove time information in output, since it's confusing anyway
blanchet
parents: 38990
diff changeset
   148
             val _ = register tool birth_time death_time desc self
43005
c96f06bffd90 merge timeout messages from several ATPs into one message to avoid clutter
blanchet
parents: 41042
diff changeset
   149
           in unregister (f ()) self end);
37584
2e289dc13615 factor out thread creation
blanchet
parents: 37583
diff changeset
   150
   ())
2e289dc13615 factor out thread creation
blanchet
parents: 37583
diff changeset
   151
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   152
fun has_running_threads tool =
57556
6180d81be977 tuned whitespace (also in strings)
blanchet
parents: 56303
diff changeset
   153
  exists (fn (_, (tool', _, _, _)) => tool' = tool) (#active (Synchronized.value global_state))
48319
340187063d84 use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents: 47945
diff changeset
   154
37583
9ce2451647d5 factored non-ATP specific code from "ATP_Manager" out, so that it can be reused for the LEO-II integration
blanchet
parents:
diff changeset
   155
end;