src/Pure/Concurrent/simple_thread.ML
author wenzelm
Thu, 09 Oct 2008 20:53:17 +0200
changeset 28550 422e9bd169ac
parent 28241 de20fccf6509
child 28577 bd2456e0d944
permissions -rw-r--r--
added fail-safe interrupt;
     1 (*  Title:      Pure/Concurrent/simple_thread.ML
     2     ID:         $Id$
     3     Author:     Makarius
     4 
     5 Simplified thread fork interface.
     6 *)
     7 
     8 signature SIMPLE_THREAD =
     9 sig
    10   val fork: bool -> (unit -> unit) -> Thread.thread
    11   val interrupt: Thread.thread -> unit
    12 end;
    13 
    14 structure SimpleThread: SIMPLE_THREAD =
    15 struct
    16 
    17 fun fork interrupts body =
    18   Thread.fork (fn () => exception_trace (fn () => body ()),
    19     if interrupts then Multithreading.regular_interrupts else Multithreading.no_interrupts);
    20 
    21 fun interrupt thread = Thread.interrupt thread handle Thread _ => ();
    22 
    23 end;