| author | wenzelm | 
| Thu, 05 Dec 2013 17:51:29 +0100 | |
| changeset 54669 | 1b153cb9699f | 
| parent 53403 | c09f4005d6bd | 
| child 56303 | 4cc3f4db3447 | 
| permissions | -rw-r--r-- | 
| 
41042
 
8275f52ac991
load "try" after "Metis" and move "Async_Manager" back to Sledgehammer
 
blanchet 
parents: 
40301 
diff
changeset
 | 
1  | 
(* Title: HOL/Tools/Sledgehammer/async_manager.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.  | 
| 
 
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
 | 
7  | 
*)  | 
| 
 
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
 | 
8  | 
|
| 
53403
 
c09f4005d6bd
some explicit indication of Proof General legacy;
 
wenzelm 
parents: 
52048 
diff
changeset
 | 
9  | 
(*Proof General legacy*)  | 
| 
 
c09f4005d6bd
some explicit indication of Proof General legacy;
 
wenzelm 
parents: 
52048 
diff
changeset
 | 
10  | 
|
| 
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
 | 
11  | 
signature ASYNC_MANAGER =  | 
| 
 
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  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
13  | 
val break_into_chunks : string -> string list  | 
| 
52048
 
9003b293e775
tuned signature -- emphasize thread creation here;
 
wenzelm 
parents: 
48319 
diff
changeset
 | 
14  | 
val thread :  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
15  | 
string -> Time.time -> Time.time -> string * string  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
16  | 
-> (unit -> bool * string) -> unit  | 
| 37585 | 17  | 
val kill_threads : string -> string -> unit  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
18  | 
val has_running_threads : string -> bool  | 
| 37585 | 19  | 
val running_threads : string -> string -> unit  | 
20  | 
val thread_messages : string -> string -> int option -> unit  | 
|
| 
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
 | 
21  | 
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
 | 
22  | 
|
| 
 
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
 | 
23  | 
structure Async_Manager : ASYNC_MANAGER =  | 
| 
 
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
 | 
24  | 
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
 | 
25  | 
|
| 
 
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
 | 
26  | 
(** preferences **)  | 
| 
 
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
 | 
27  | 
|
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
28  | 
val message_store_limit = 20  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
29  | 
val message_display_limit = 10  | 
| 
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
 | 
30  | 
|
| 
 
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
 | 
31  | 
|
| 
 
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
 | 
32  | 
(** thread management **)  | 
| 
 
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  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
34  | 
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
 | 
35  | 
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
 | 
36  | 
|
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
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  | 
(* data structures over threads *)  | 
| 
 
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
 | 
39  | 
|
| 
 
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
 | 
40  | 
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
 | 
41  | 
(  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
42  | 
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
 | 
43  | 
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
 | 
44  | 
)  | 
| 
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
 | 
45  | 
|
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
46  | 
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
 | 
47  | 
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
 | 
48  | 
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
 | 
49  | 
|
| 
 
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
 | 
50  | 
|
| 
 
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  | 
(* state of thread manager *)  | 
| 
 
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
 | 
52  | 
|
| 
 
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
 | 
53  | 
type state =  | 
| 37585 | 54  | 
  {manager: Thread.thread option,
 | 
55  | 
timeout_heap: Thread_Heap.T,  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
56  | 
active:  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
57  | 
(Thread.thread  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
58  | 
* (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
 | 
59  | 
canceling: (Thread.thread * (string * Time.time * (string * string))) list,  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
60  | 
messages: (bool * (string * (string * string))) list,  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
61  | 
store: (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
 | 
62  | 
|
| 
 
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  | 
fun make_state manager timeout_heap active canceling messages store : 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
 | 
64  | 
  {manager = manager, timeout_heap = timeout_heap, active = active,
 | 
| 
 
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  | 
canceling = canceling, messages = messages, store = store}  | 
| 
 
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
 | 
66  | 
|
| 
 
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
 | 
67  | 
val global_state = Synchronized.var "async_manager"  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
68  | 
(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
 | 
69  | 
|
| 
 
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
 | 
70  | 
|
| 
 
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
 | 
71  | 
(* unregister thread *)  | 
| 
 
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  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
73  | 
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
 | 
74  | 
Synchronized.change global_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
 | 
75  | 
  (fn state as {manager, timeout_heap, active, canceling, messages, store} =>
 | 
| 
 
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
 | 
76  | 
(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
 | 
77  | 
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
 | 
78  | 
let  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
79  | 
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
 | 
80  | 
val now = Time.now ()  | 
| 37585 | 81  | 
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
 | 
82  | 
val message' =  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
83  | 
(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
 | 
84  | 
val messages' = (urgent, (tool, message')) :: messages  | 
| 37585 | 85  | 
val store' = (tool, message') ::  | 
| 
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
 | 
86  | 
(if length store <= message_store_limit then store  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
87  | 
else #1 (chop message_store_limit store))  | 
| 
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
 | 
88  | 
in make_state manager timeout_heap active' canceling' messages' store' end  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
89  | 
| 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
 | 
90  | 
|
| 
 
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  | 
|
| 
 
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
 | 
92  | 
(* main manager thread -- only one may exist *)  | 
| 
 
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
 | 
93  | 
|
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
94  | 
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
 | 
95  | 
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
 | 
96  | 
|
| 
 
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 replace_all bef aft =  | 
| 
 
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  | 
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
 | 
99  | 
fun aux seen "" = String.implode (rev seen)  | 
| 
 
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
 | 
100  | 
| aux seen s =  | 
| 
 
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  | 
if String.isPrefix bef s then  | 
| 
 
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  | 
aux seen "" ^ aft ^ aux [] (unprefix bef s)  | 
| 
 
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
 | 
103  | 
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
 | 
104  | 
aux (String.sub (s, 0) :: seen) (String.extract (s, 1, NONE))  | 
| 
 
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
 | 
105  | 
in aux [] 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
 | 
106  | 
|
| 
 
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
 | 
107  | 
(* This is a workaround for Proof General's off-by-a-few sendback display bug,  | 
| 
 
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
 | 
108  | 
whereby "pr" in "proof" is not highlighted. *)  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
109  | 
val break_into_chunks = space_explode "\000" o replace_all "\n\n" "\000"  | 
| 
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
 | 
110  | 
|
| 37585 | 111  | 
fun print_new_messages () =  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
112  | 
Synchronized.change_result global_state  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
113  | 
      (fn {manager, timeout_heap, active, canceling, messages, store} =>
 | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
114  | 
messages  | 
| 43055 | 115  | 
|> List.partition  | 
116  | 
(fn (urgent, _) =>  | 
|
117  | 
(null active andalso null canceling) orelse urgent)  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
118  | 
||> (fn postponed_messages =>  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
119  | 
make_state manager timeout_heap active canceling  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
120  | 
postponed_messages store))  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
121  | 
|> 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
 | 
122  | 
|> AList.group (op =)  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
123  | 
|> List.app (fn ((_, ""), _) => ()  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
124  | 
| ((tool, work), workers) =>  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
125  | 
tool ^ ": " ^  | 
| 47945 | 126  | 
implode_message (workers |> sort_distinct string_ord, work)  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
127  | 
|> break_into_chunks  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
128  | 
|> List.app Output.urgent_message)  | 
| 
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
 | 
129  | 
|
| 
39006
 
a02cb5717677
remove time information in output, since it's confusing anyway
 
blanchet 
parents: 
38990 
diff
changeset
 | 
130  | 
fun check_thread_manager () = Synchronized.change global_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
 | 
131  | 
  (fn state as {manager, timeout_heap, active, canceling, messages, store} =>
 | 
| 
 
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  | 
if (case manager of SOME thread => Thread.isActive thread | NONE => false) then 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
 | 
133  | 
else let val manager = SOME (Toplevel.thread false (fn () =>  | 
| 
 
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  | 
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
 | 
135  | 
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
 | 
136  | 
(case try Thread_Heap.min timeout_heap of  | 
| 
 
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
 | 
137  | 
NONE => Time.+ (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
 | 
138  | 
| 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
 | 
139  | 
|
| 
 
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  | 
(*action: find threads whose timeout is reached, and interrupt canceling threads*)  | 
| 
 
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
 | 
141  | 
        fun action {manager, timeout_heap, active, canceling, messages, store} =
 | 
| 
 
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  | 
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
 | 
143  | 
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
 | 
144  | 
in  | 
| 37585 | 145  | 
if null timeout_threads andalso null canceling then  | 
146  | 
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
 | 
147  | 
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
 | 
148  | 
let  | 
| 
44112
 
ef876972fdc1
more explicit Simple_Thread.interrupt_unsynchronized, to emphasize its meaning;
 
wenzelm 
parents: 
43055 
diff
changeset
 | 
149  | 
val _ = List.app (Simple_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
 | 
150  | 
val canceling' = filter (Thread.isActive o #1) canceling  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
151  | 
val state' = make_state manager timeout_heap' active canceling' messages store  | 
| 
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
 | 
152  | 
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
 | 
153  | 
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
 | 
154  | 
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
 | 
155  | 
while Synchronized.change_result global_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
 | 
156  | 
          (fn state as {timeout_heap, active, canceling, messages, store, ...} =>
 | 
| 
 
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
 | 
157  | 
if null active andalso null canceling andalso null messages  | 
| 
 
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
 | 
158  | 
then (false, make_state NONE timeout_heap active canceling messages store)  | 
| 
 
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
 | 
159  | 
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
 | 
160  | 
do  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
161  | 
(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
 | 
162  | 
(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
 | 
163  | 
|> these  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
164  | 
|> 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
 | 
165  | 
print_new_messages ();  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
166  | 
(* 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
 | 
167  | 
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
 | 
168  | 
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
 | 
169  | 
in make_state manager timeout_heap active canceling messages store 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
 | 
170  | 
|
| 
 
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
 | 
171  | 
|
| 
 
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
 | 
172  | 
(* register thread *)  | 
| 
 
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
 | 
173  | 
|
| 
39006
 
a02cb5717677
remove time information in output, since it's confusing anyway
 
blanchet 
parents: 
38990 
diff
changeset
 | 
174  | 
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
 | 
175  | 
(Synchronized.change global_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
 | 
176  | 
    (fn {manager, timeout_heap, active, canceling, messages, store} =>
 | 
| 
 
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
 | 
177  | 
let  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
178  | 
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
 | 
179  | 
val active' = update_thread (thread, (tool, birth_time, death_time, desc)) active  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
180  | 
val state' = make_state manager timeout_heap' active' canceling messages store  | 
| 
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
 | 
181  | 
in state' end);  | 
| 
39006
 
a02cb5717677
remove time information in output, since it's confusing anyway
 
blanchet 
parents: 
38990 
diff
changeset
 | 
182  | 
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
 | 
183  | 
|
| 
 
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
 | 
184  | 
|
| 
52048
 
9003b293e775
tuned signature -- emphasize thread creation here;
 
wenzelm 
parents: 
48319 
diff
changeset
 | 
185  | 
fun thread tool birth_time death_time desc f =  | 
| 37584 | 186  | 
(Toplevel.thread true  | 
187  | 
(fn () =>  | 
|
188  | 
let  | 
|
189  | 
val self = Thread.self ()  | 
|
| 
39006
 
a02cb5717677
remove time information in output, since it's confusing anyway
 
blanchet 
parents: 
38990 
diff
changeset
 | 
190  | 
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
 | 
191  | 
in unregister (f ()) self end);  | 
| 37584 | 192  | 
())  | 
193  | 
||
| 
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
 | 
194  | 
|
| 
 
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
 | 
195  | 
(** user commands **)  | 
| 
 
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
 | 
196  | 
|
| 
 
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
 | 
197  | 
(* kill threads *)  | 
| 
 
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
 | 
198  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
199  | 
fun kill_threads tool das_wort_worker = Synchronized.change global_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
 | 
200  | 
  (fn {manager, timeout_heap, active, canceling, messages, store} =>
 | 
| 
 
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
 | 
201  | 
let  | 
| 37585 | 202  | 
val killing =  | 
203  | 
map_filter (fn (th, (tool', _, _, desc)) =>  | 
|
204  | 
if tool' = tool then SOME (th, (tool', Time.now (), desc))  | 
|
205  | 
else NONE) active  | 
|
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
206  | 
val state' = make_state manager timeout_heap [] (killing @ canceling) messages store  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
207  | 
val _ =  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
208  | 
if null killing then ()  | 
| 45573 | 209  | 
        else Output.urgent_message ("Interrupted active " ^ das_wort_worker ^ "s.")
 | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
210  | 
in state' 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
 | 
211  | 
|
| 
 
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
 | 
212  | 
|
| 
 
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
 | 
213  | 
(* running threads *)  | 
| 
 
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
 | 
214  | 
|
| 37585 | 215  | 
fun seconds time = string_of_int (Time.toSeconds time) ^ " s"  | 
| 
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
 | 
216  | 
|
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
217  | 
fun has_running_threads tool =  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
218  | 
exists (fn (_, (tool', _, _, _)) => tool' = tool)  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
219  | 
(#active (Synchronized.value global_state))  | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
220  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
221  | 
fun running_threads tool das_wort_worker =  | 
| 
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
 | 
222  | 
let  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
223  | 
    val {active, canceling, ...} = Synchronized.value global_state
 | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
224  | 
val now = Time.now ()  | 
| 37585 | 225  | 
fun running_info (_, (tool', birth_time, death_time, desc)) =  | 
226  | 
if tool' = tool then  | 
|
227  | 
        SOME ("Running: " ^ seconds (Time.- (now, birth_time)) ^ " -- " ^
 | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
228  | 
seconds (Time.- (death_time, now)) ^ " to live:\n" ^  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
229  | 
op ^ desc)  | 
| 37585 | 230  | 
else  | 
231  | 
NONE  | 
|
232  | 
fun canceling_info (_, (tool', death_time, desc)) =  | 
|
233  | 
if tool' = tool then  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
234  | 
        SOME ("Trying to interrupt " ^ das_wort_worker ^ " since " ^
 | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
235  | 
seconds (Time.- (now, death_time)) ^ ":\n" ^ op ^ desc)  | 
| 37585 | 236  | 
else  | 
237  | 
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
 | 
238  | 
val running =  | 
| 37585 | 239  | 
case map_filter running_info active of  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
240  | 
[] => ["No " ^ das_wort_worker ^ "s running."]  | 
| 
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
241  | 
| ss => "Running " ^ das_wort_worker ^ "s " :: ss  | 
| 
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
 | 
242  | 
val interrupting =  | 
| 37585 | 243  | 
case map_filter canceling_info canceling of  | 
| 
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
 | 
244  | 
[] => []  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
245  | 
| ss => "Interrupting " ^ das_wort_worker ^ "s " :: ss  | 
| 
40132
 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 
wenzelm 
parents: 
39376 
diff
changeset
 | 
246  | 
in Output.urgent_message (space_implode "\n\n" (running @ interrupting)) 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
 | 
247  | 
|
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
248  | 
fun thread_messages tool das_wort_worker opt_limit =  | 
| 
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
 | 
249  | 
let  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
250  | 
val limit = the_default message_display_limit opt_limit  | 
| 37585 | 251  | 
val tool_store = Synchronized.value global_state  | 
252  | 
|> #store |> filter (curry (op =) tool o fst)  | 
|
| 
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
 | 
253  | 
val header =  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
254  | 
"Recent " ^ das_wort_worker ^ " messages" ^  | 
| 37585 | 255  | 
(if length tool_store <= limit then ":"  | 
| 
48319
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
256  | 
         else " (" ^ string_of_int limit ^ " displayed):")
 | 
| 
 
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
 
blanchet 
parents: 
47945 
diff
changeset
 | 
257  | 
val ss = tool_store |> chop limit |> #1 |> map (op ^ o snd)  | 
| 
43005
 
c96f06bffd90
merge timeout messages from several ATPs into one message to avoid clutter
 
blanchet 
parents: 
41042 
diff
changeset
 | 
258  | 
in List.app Output.urgent_message (header :: maps break_into_chunks ss) 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
 | 
259  | 
|
| 
 
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
 | 
260  | 
end;  |