src/Pure/ML-Systems/smlnj.ML
changeset 23965 f93e509659c1
parent 23921 947152add153
child 24145 c6402b61d44a
     1.1 --- a/src/Pure/ML-Systems/smlnj.ML	Tue Jul 24 19:44:36 2007 +0200
     1.2 +++ b/src/Pure/ML-Systems/smlnj.ML	Tue Jul 24 19:44:37 2007 +0200
     1.3 @@ -4,7 +4,8 @@
     1.4  Compatibility file for Standard ML of New Jersey 110 or later.
     1.5  *)
     1.6  
     1.7 -use "ML-Systems/no_multithreading.ML";
     1.8 +use "ML-Systems/exn.ML";
     1.9 +use "ML-Systems/multithreading_dummy.ML";
    1.10  
    1.11  
    1.12  (** ML system related **)
    1.13 @@ -127,37 +128,26 @@
    1.14  
    1.15  exception Interrupt;
    1.16  
    1.17 -local
    1.18 -
    1.19 -fun capture f x = ((f x): unit; NONE) handle exn => SOME exn;
    1.20 -
    1.21 -fun release NONE = ()
    1.22 -  | release (SOME exn) = raise exn;
    1.23 -
    1.24 -in
    1.25 -
    1.26  fun ignore_interrupt f x =
    1.27    let
    1.28      val old_handler = Signals.setHandler (Signals.sigINT, Signals.IGNORE);
    1.29 -    val result = capture f x;
    1.30 +    val result = Exn.capture f x;
    1.31      val _ = Signals.setHandler (Signals.sigINT, old_handler);
    1.32 -  in release result end;
    1.33 +  in Exn.release result end;
    1.34  
    1.35  fun raise_interrupt f x =
    1.36    let
    1.37      val interrupted = ref false;
    1.38 -    val result = ref NONE;
    1.39 +    val result = ref (Exn.Result ());
    1.40      val old_handler = Signals.inqHandler Signals.sigINT;
    1.41    in
    1.42      SMLofNJ.Cont.callcc (fn cont =>
    1.43        (Signals.setHandler (Signals.sigINT, Signals.HANDLER (fn _ => (interrupted := true; cont)));
    1.44 -      result := capture f x));
    1.45 +      result := Exn.capture f x));
    1.46      Signals.setHandler (Signals.sigINT, old_handler);
    1.47 -    if ! interrupted then raise Interrupt else release (! result)
    1.48 +    if ! interrupted then raise Interrupt else Exn.release (! result)
    1.49    end;
    1.50  
    1.51 -end;
    1.52 -
    1.53  
    1.54  (* basis library fixes *)
    1.55