157 fun read_command channel = |
157 fun read_command channel = |
158 (case System_Channel.input_line channel of |
158 (case System_Channel.input_line channel of |
159 NONE => raise Runtime.TERMINATE |
159 NONE => raise Runtime.TERMINATE |
160 | SOME line => map (read_chunk channel) (space_explode "," line)); |
160 | SOME line => map (read_chunk channel) (space_explode "," line)); |
161 |
161 |
162 fun worker_guest e = |
162 fun worker_context e = |
163 Future.worker_guest "Isabelle_Process.loop" (Future.new_group NONE) e (); |
163 Future.worker_context "Isabelle_Process.loop" (Future.new_group NONE) e (); |
164 |
164 |
165 in |
165 in |
166 |
166 |
167 fun loop channel = |
167 fun loop channel = |
168 let val continue = |
168 let val continue = |
169 (case read_command channel of |
169 (case read_command channel of |
170 [] => (Output.error_msg "Isabelle process: no input"; true) |
170 [] => (Output.error_msg "Isabelle process: no input"; true) |
171 | name :: args => (worker_guest (fn () => run_command name args); true)) |
171 | name :: args => (worker_context (fn () => run_command name args); true)) |
172 handle Runtime.TERMINATE => false |
172 handle Runtime.TERMINATE => false |
173 | exn => (Output.error_msg (ML_Compiler.exn_message exn) handle crash => recover crash; true); |
173 | exn => (Output.error_msg (ML_Compiler.exn_message exn) handle crash => recover crash; true); |
174 in |
174 in |
175 if continue then loop channel |
175 if continue then loop channel |
176 else (Future.shutdown (); Execution.reset (); ()) |
176 else (Future.shutdown (); Execution.reset (); ()) |