equal
deleted
inserted
replaced
23 val join: T -> unit |
23 val join: T -> unit |
24 val interrupt: exn |
24 val interrupt: exn |
25 val interrupt_exn: 'a Exn.result |
25 val interrupt_exn: 'a Exn.result |
26 val interrupt_self: unit -> 'a |
26 val interrupt_self: unit -> 'a |
27 val interrupt_other: T -> unit |
27 val interrupt_other: T -> unit |
|
28 val expose_interrupt: unit -> unit (*exception Interrupt*) |
28 val try_catch: (unit -> 'a) -> (exn -> 'a) -> 'a |
29 val try_catch: (unit -> 'a) -> (exn -> 'a) -> 'a |
29 val try_finally: (unit -> 'a) -> (unit -> unit) -> 'a |
30 val try_finally: (unit -> 'a) -> (unit -> unit) -> 'a |
30 val try: (unit -> 'a) -> 'a option |
31 val try: (unit -> 'a) -> 'a option |
31 val can: (unit -> 'a) -> bool |
32 val can: (unit -> 'a) -> bool |
32 end; |
33 end; |
119 fun interrupt_self () = raise interrupt; |
120 fun interrupt_self () = raise interrupt; |
120 |
121 |
121 fun interrupt_other t = |
122 fun interrupt_other t = |
122 Thread.Thread.interrupt (get_thread t) handle Thread.Thread _ => (); |
123 Thread.Thread.interrupt (get_thread t) handle Thread.Thread _ => (); |
123 |
124 |
|
125 fun expose_interrupt () = |
|
126 let |
|
127 val orig_atts = Thread_Attributes.safe_interrupts (Thread_Attributes.get_attributes ()); |
|
128 val _ = Thread_Attributes.set_attributes Thread_Attributes.test_interrupts; |
|
129 val test = Exn.capture Thread.Thread.testInterrupt (); |
|
130 val _ = Thread_Attributes.set_attributes orig_atts; |
|
131 in Exn.release test end; |
|
132 |
124 fun try_catch e f = |
133 fun try_catch e f = |
125 Thread_Attributes.uninterruptible (fn restore_attributes => fn () => |
134 Thread_Attributes.uninterruptible (fn restore_attributes => fn () => |
126 restore_attributes e () |
135 restore_attributes e () |
127 handle exn => if Exn.is_interrupt exn then Exn.reraise exn else f exn) (); |
136 handle exn => if Exn.is_interrupt exn then Exn.reraise exn else f exn) (); |
128 |
137 |