equal
deleted
inserted
replaced
83 def apply(thread: Isabelle_Thread) { handle(thread) } |
83 def apply(thread: Isabelle_Thread) { handle(thread) } |
84 override def toString: String = name |
84 override def toString: String = name |
85 } |
85 } |
86 |
86 |
87 def interrupt_handler[A](handler: Interrupt_Handler)(body: => A): A = |
87 def interrupt_handler[A](handler: Interrupt_Handler)(body: => A): A = |
88 self.interrupt_handler(handler)(body) |
88 if (handler == null) body |
|
89 else self.interrupt_handler(handler)(body) |
89 |
90 |
90 def interrupt_handler[A](handle: Isabelle_Thread => Unit)(body: => A): A = |
91 def interrupt_handler[A](handle: Isabelle_Thread => Unit)(body: => A): A = |
91 self.interrupt_handler(Interrupt_Handler(handle))(body) |
92 self.interrupt_handler(Interrupt_Handler(handle))(body) |
92 |
93 |
93 def interruptible[A](body: => A): A = |
94 def interruptible[A](body: => A): A = |
148 @volatile private var handler = Isabelle_Thread.Interrupt_Handler.interruptible |
149 @volatile private var handler = Isabelle_Thread.Interrupt_Handler.interruptible |
149 |
150 |
150 override def interrupt: Unit = handler(thread) |
151 override def interrupt: Unit = handler(thread) |
151 |
152 |
152 def interrupt_handler[A](new_handler: Isabelle_Thread.Interrupt_Handler)(body: => A): A = |
153 def interrupt_handler[A](new_handler: Isabelle_Thread.Interrupt_Handler)(body: => A): A = |
153 { |
154 if (new_handler == null) body |
154 require(is_self) |
155 else { |
|
156 require(is_self) |
155 |
157 |
156 val old_handler = handler |
158 val old_handler = handler |
157 handler = new_handler |
159 handler = new_handler |
158 try { |
160 try { |
159 if (clear_interrupt) interrupt |
161 if (clear_interrupt) interrupt |
160 body |
162 body |
|
163 } |
|
164 finally { |
|
165 handler = old_handler |
|
166 if (clear_interrupt) interrupt |
|
167 } |
161 } |
168 } |
162 finally { |
|
163 handler = old_handler |
|
164 if (clear_interrupt) interrupt |
|
165 } |
|
166 } |
|
167 } |
169 } |