src/Pure/Concurrent/isabelle_thread.ML
changeset 78715 9506b852ebdf
parent 78714 eb2255d241da
child 78716 97dfba4405e3
equal deleted inserted replaced
78714:eb2255d241da 78715:9506b852ebdf
    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   structure Exn: EXN
    28   val expose_interrupt_result: unit -> unit Exn.result
    29   val expose_interrupt_result: unit -> unit Exn.result
    29   val expose_interrupt: unit -> unit  (*exception Interrupt*)
    30   val expose_interrupt: unit -> unit  (*exception Interrupt*)
    30   val try_catch: (unit -> 'a) -> (exn -> 'a) -> 'a
    31   val try_catch: (unit -> 'a) -> (exn -> 'a) -> 'a
    31   val try_finally: (unit -> 'a) -> (unit -> unit) -> 'a
    32   val try_finally: (unit -> 'a) -> (unit -> unit) -> 'a
    32   val try: (unit -> 'a) -> 'a option
    33   val try: (unit -> 'a) -> 'a option
   121 fun interrupt_self () = raise interrupt;
   122 fun interrupt_self () = raise interrupt;
   122 
   123 
   123 fun interrupt_other t =
   124 fun interrupt_other t =
   124   Thread.Thread.interrupt (get_thread t) handle Thread.Thread _ => ();
   125   Thread.Thread.interrupt (get_thread t) handle Thread.Thread _ => ();
   125 
   126 
       
   127 structure Exn: EXN =
       
   128 struct
       
   129   open Exn;
       
   130   val capture = capture0;
       
   131 end;
       
   132 
   126 fun expose_interrupt_result () =
   133 fun expose_interrupt_result () =
   127   let
   134   let
   128     val orig_atts = Thread_Attributes.safe_interrupts (Thread_Attributes.get_attributes ());
   135     val orig_atts = Thread_Attributes.safe_interrupts (Thread_Attributes.get_attributes ());
   129     val _ = Thread_Attributes.set_attributes Thread_Attributes.test_interrupts;
   136     val _ = Thread_Attributes.set_attributes Thread_Attributes.test_interrupts;
   130     val test = Exn.capture Thread.Thread.testInterrupt ();
   137     val test = Exn.capture Thread.Thread.testInterrupt ();
   144 
   151 
   145 fun try e = Basics.try e ();
   152 fun try e = Basics.try e ();
   146 fun can e = Basics.can e ();
   153 fun can e = Basics.can e ();
   147 
   154 
   148 end;
   155 end;
       
   156 
       
   157 structure Exn = Isabelle_Thread.Exn;