equal
deleted
inserted
replaced
146 |
146 |
147 structure Exn: EXN = |
147 structure Exn: EXN = |
148 struct |
148 struct |
149 open Exn; |
149 open Exn; |
150 val capture = capture0; |
150 val capture = capture0; |
|
151 fun capture_body e = capture e (); |
151 end; |
152 end; |
152 |
153 |
153 fun expose_interrupt_result () = |
154 fun expose_interrupt_result () = |
154 let |
155 let |
155 val orig_atts = Thread_Attributes.safe_interrupts (Thread_Attributes.get_attributes ()); |
156 val orig_atts = Thread_Attributes.safe_interrupts (Thread_Attributes.get_attributes ()); |
156 fun main () = |
157 fun main () = |
157 (Thread_Attributes.set_attributes Thread_Attributes.test_interrupts; |
158 (Thread_Attributes.set_attributes Thread_Attributes.test_interrupts; |
158 Thread.Thread.testInterrupt ()); |
159 Thread.Thread.testInterrupt ()); |
159 val test = Exn.capture main (); |
160 val test = Exn.capture_body main; |
160 val _ = Thread_Attributes.set_attributes orig_atts; |
161 val _ = Thread_Attributes.set_attributes orig_atts; |
161 in test end; |
162 in test end; |
162 |
163 |
163 val expose_interrupt = Exn.release o expose_interrupt_result; |
164 val expose_interrupt = Exn.release o expose_interrupt_result; |
164 |
165 |
166 Thread_Attributes.uninterruptible_body (fn run => |
167 Thread_Attributes.uninterruptible_body (fn run => |
167 run e () handle exn => if Exn.is_interrupt exn then Exn.reraise exn else f exn); |
168 run e () handle exn => if Exn.is_interrupt exn then Exn.reraise exn else f exn); |
168 |
169 |
169 fun try_finally e f = |
170 fun try_finally e f = |
170 Thread_Attributes.uninterruptible_body (fn run => |
171 Thread_Attributes.uninterruptible_body (fn run => |
171 Exn.release (Exn.capture (run e) () before f ())); |
172 Exn.release (Exn.capture_body (run e) before f ())); |
172 |
173 |
173 fun try e = Basics.try e (); |
174 fun try e = Basics.try e (); |
174 fun can e = Basics.can e (); |
175 fun can e = Basics.can e (); |
175 |
176 |
176 end; |
177 end; |