equal
deleted
inserted
replaced
48 case object Shutdown extends Phase // transient |
48 case object Shutdown extends Phase // transient |
49 //}}} |
49 //}}} |
50 |
50 |
51 |
51 |
52 /* protocol handlers */ |
52 /* protocol handlers */ |
53 |
|
54 type Prover = Isabelle_Process with Protocol |
|
55 |
53 |
56 abstract class Protocol_Handler |
54 abstract class Protocol_Handler |
57 { |
55 { |
58 def stop(prover: Prover): Unit = {} |
56 def stop(prover: Prover): Unit = {} |
59 val functions: Map[String, (Prover, Prover.Protocol_Output) => Boolean] |
57 val functions: Map[String, (Prover, Prover.Protocol_Output) => Boolean] |
256 } |
254 } |
257 |
255 |
258 |
256 |
259 /* actor messages */ |
257 /* actor messages */ |
260 |
258 |
261 private case class Start(args: List[String]) |
259 private case class Start(name: String, args: List[String]) |
262 private case class Cancel_Exec(exec_id: Document_ID.Exec) |
260 private case class Cancel_Exec(exec_id: Document_ID.Exec) |
263 private case class Protocol_Command(name: String, args: List[String]) |
261 private case class Protocol_Command(name: String, args: List[String]) |
264 private case class Messages(msgs: List[Prover.Message]) |
262 private case class Messages(msgs: List[Prover.Message]) |
265 private case class Update_Options(options: Options) |
263 private case class Update_Options(options: Options) |
266 |
264 |
305 timer.schedule(new TimerTask { def run = flush }, message_delay.ms, message_delay.ms) |
303 timer.schedule(new TimerTask { def run = flush }, message_delay.ms, message_delay.ms) |
306 |
304 |
307 def cancel() { timer.cancel() } |
305 def cancel() { timer.cancel() } |
308 } |
306 } |
309 |
307 |
310 var prover: Option[Session.Prover] = None |
308 var prover: Option[Prover] = None |
311 |
309 |
312 |
310 |
313 /* delayed command changes */ |
311 /* delayed command changes */ |
314 |
312 |
315 object delay_commands_changed |
313 object delay_commands_changed |
503 var finished = false |
501 var finished = false |
504 while (!finished) { |
502 while (!finished) { |
505 receiveWithin(delay_commands_changed.flush_timeout) { |
503 receiveWithin(delay_commands_changed.flush_timeout) { |
506 case TIMEOUT => delay_commands_changed.flush() |
504 case TIMEOUT => delay_commands_changed.flush() |
507 |
505 |
508 case Start(args) if prover.isEmpty => |
506 case Start(name, args) if prover.isEmpty => |
509 if (phase == Session.Inactive || phase == Session.Failed) { |
507 if (phase == Session.Inactive || phase == Session.Failed) { |
510 phase = Session.Startup |
508 phase = Session.Startup |
511 prover = Some(new Isabelle_Process(receiver.invoke _, args) with Protocol) |
509 prover = Some(resources.start_prover(receiver.invoke _, name, args)) |
512 } |
510 } |
513 |
511 |
514 case Stop => |
512 case Stop => |
515 if (phase == Session.Ready) { |
513 if (phase == Session.Ready) { |
516 _protocol_handlers = _protocol_handlers.stop(prover.get) |
514 _protocol_handlers = _protocol_handlers.stop(prover.get) |
570 } |
568 } |
571 |
569 |
572 |
570 |
573 /* actions */ |
571 /* actions */ |
574 |
572 |
575 def start(args: List[String]) |
573 def start(name: String, args: List[String]) |
576 { |
574 { |
577 session_actor ! Start(args) |
575 session_actor ! Start(name, args) |
578 } |
576 } |
579 |
577 |
580 def stop() |
578 def stop() |
581 { |
579 { |
582 commands_changed_buffer !? Stop |
580 commands_changed_buffer !? Stop |