equal
deleted
inserted
replaced
105 |
105 |
106 /* protocol handlers */ |
106 /* protocol handlers */ |
107 |
107 |
108 abstract class Protocol_Handler |
108 abstract class Protocol_Handler |
109 { |
109 { |
110 def start(prover: Prover): Unit = {} |
110 def start(session: Session, prover: Prover): Unit = {} |
111 def stop(prover: Prover): Unit = {} |
111 def stop(prover: Prover): Unit = {} |
112 val functions: Map[String, (Prover, Prover.Protocol_Output) => Boolean] |
112 val functions: Map[String, (Prover, Prover.Protocol_Output) => Boolean] |
113 } |
113 } |
114 |
114 |
115 def bad_protocol_handler(exn: Throwable, name: String): Unit = |
115 def bad_protocol_handler(exn: Throwable, name: String): Unit = |
120 handlers: Map[String, Session.Protocol_Handler] = Map.empty, |
120 handlers: Map[String, Session.Protocol_Handler] = Map.empty, |
121 functions: Map[String, Prover.Protocol_Output => Boolean] = Map.empty) |
121 functions: Map[String, Prover.Protocol_Output => Boolean] = Map.empty) |
122 { |
122 { |
123 def get(name: String): Option[Protocol_Handler] = handlers.get(name) |
123 def get(name: String): Option[Protocol_Handler] = handlers.get(name) |
124 |
124 |
125 def add(prover: Prover, handler: Protocol_Handler): Protocol_Handlers = |
125 def add(session: Session, prover: Prover, handler: Protocol_Handler): Protocol_Handlers = |
126 { |
126 { |
127 val name = handler.getClass.getName |
127 val name = handler.getClass.getName |
128 |
128 |
129 val (handlers1, functions1) = |
129 val (handlers1, functions1) = |
130 handlers.get(name) match { |
130 handlers.get(name) match { |
135 case None => (handlers, functions) |
135 case None => (handlers, functions) |
136 } |
136 } |
137 |
137 |
138 val (handlers2, functions2) = |
138 val (handlers2, functions2) = |
139 try { |
139 try { |
140 handler.start(prover) |
140 handler.start(session, prover) |
141 |
141 |
142 val new_functions = |
142 val new_functions = |
143 for ((a, f) <- handler.functions.toList) yield |
143 for ((a, f) <- handler.functions.toList) yield |
144 (a, (msg: Prover.Protocol_Output) => f(prover, msg)) |
144 (a, (msg: Prover.Protocol_Output) => f(prover, msg)) |
145 |
145 |
347 |
347 |
348 def get_protocol_handler(name: String): Option[Session.Protocol_Handler] = |
348 def get_protocol_handler(name: String): Option[Session.Protocol_Handler] = |
349 _protocol_handlers.value.get(name) |
349 _protocol_handlers.value.get(name) |
350 |
350 |
351 def add_protocol_handler(handler: Session.Protocol_Handler): Unit = |
351 def add_protocol_handler(handler: Session.Protocol_Handler): Unit = |
352 _protocol_handlers.change(_.add(prover.get, handler)) |
352 _protocol_handlers.change(_.add(this, prover.get, handler)) |
353 |
353 |
354 |
354 |
355 /* manager thread */ |
355 /* manager thread */ |
356 |
356 |
357 private val delay_prune = |
357 private val delay_prune = |