force: non-critical, but also non-thread-safe (potentially multiple evaluations);
1.1 --- a/src/Pure/General/susp.ML Thu Aug 16 21:52:07 2007 +0200
1.2 +++ b/src/Pure/General/susp.ML Thu Aug 16 21:52:08 2007 +0200
1.3 @@ -2,7 +2,8 @@
1.4 ID: $Id$
1.5 Author: Sebastian Skalberg and Florian Haftmann, TU Muenchen
1.6
1.7 -Delayed evaluation.
1.8 +Delayed evaluation. Supposed to be value oriented; may result in
1.9 +multiple evaluations in a multi-threaded environment!
1.10 *)
1.11
1.12 signature SUSP =
1.13 @@ -28,14 +29,14 @@
1.14
1.15 fun delay f = ref (Delay f);
1.16
1.17 -fun force susp = NAMED_CRITICAL "susp" (fn () =>
1.18 +fun force susp =
1.19 (case ! susp of
1.20 Value v => v
1.21 | Delay f =>
1.22 let
1.23 val v = f ();
1.24 val _ = susp := Value v;
1.25 - in v end));
1.26 + in v end);
1.27
1.28 fun peek susp =
1.29 (case ! susp of
1.30 @@ -44,4 +45,4 @@
1.31
1.32 fun same (r1 : 'a T, r2) = (r1 = r2); (*equality on references*)
1.33
1.34 -end
1.35 +end;