src/Pure/Concurrent/multithreading.ML
changeset 62892 7485507620b6
parent 62891 7a11ea5c9626
child 62918 2fcbd4abc021
equal deleted inserted replaced
62891:7a11ea5c9626 62892:7485507620b6
    10   val public_interrupts: Thread.threadAttribute list
    10   val public_interrupts: Thread.threadAttribute list
    11   val private_interrupts: Thread.threadAttribute list
    11   val private_interrupts: Thread.threadAttribute list
    12   val sync_interrupts: Thread.threadAttribute list -> Thread.threadAttribute list
    12   val sync_interrupts: Thread.threadAttribute list -> Thread.threadAttribute list
    13   val interrupted: unit -> unit  (*exception Interrupt*)
    13   val interrupted: unit -> unit  (*exception Interrupt*)
    14   val with_attributes: Thread.threadAttribute list -> (Thread.threadAttribute list -> 'a) -> 'a
    14   val with_attributes: Thread.threadAttribute list -> (Thread.threadAttribute list -> 'a) -> 'a
    15   val interruptible: ('a -> 'b) -> 'a -> 'b
       
    16   val uninterruptible: ((('c -> 'd) -> 'c -> 'd) -> 'a -> 'b) -> 'a -> 'b
    15   val uninterruptible: ((('c -> 'd) -> 'c -> 'd) -> 'a -> 'b) -> 'a -> 'b
    17   val max_threads_value: unit -> int
    16   val max_threads_value: unit -> int
    18   val max_threads_update: int -> unit
    17   val max_threads_update: int -> unit
    19   val enabled: unit -> bool
    18   val enabled: unit -> bool
    20   val sync_wait: Thread.threadAttribute list option -> Time.time option ->
    19   val sync_wait: Thread.threadAttribute list option -> Time.time option ->
    67     val orig_atts = safe_interrupts (Thread.getAttributes ());
    66     val orig_atts = safe_interrupts (Thread.getAttributes ());
    68     val result = Exn.capture (fn () =>
    67     val result = Exn.capture (fn () =>
    69       (Thread.setAttributes (safe_interrupts new_atts); e orig_atts)) ();
    68       (Thread.setAttributes (safe_interrupts new_atts); e orig_atts)) ();
    70     val _ = Thread.setAttributes orig_atts;
    69     val _ = Thread.setAttributes orig_atts;
    71   in Exn.release result end;
    70   in Exn.release result end;
    72 
       
    73 fun interruptible f x = with_attributes public_interrupts (fn _ => f x);
       
    74 
    71 
    75 fun uninterruptible f x =
    72 fun uninterruptible f x =
    76   with_attributes no_interrupts (fn atts =>
    73   with_attributes no_interrupts (fn atts =>
    77     f (fn g => fn y => with_attributes atts (fn _ => g y)) x);
    74     f (fn g => fn y => with_attributes atts (fn _ => g y)) x);
    78 
    75