[MLton-user] MLton.Finalizable.touch
Florian Weimer
fw@deneb.enyo.de
Fri, 26 Aug 2005 12:18:11 +0200
* Stephen Weeks:
> I've committed a fix to our SVN repository. Unfortunately, the fix is
> not just a basis library change, so you need to rebuild MLton from the
> repository in order for the fix to take effect.
Thanks a lot for quickly fixing this bug.
Below are two additional test cases. The first one is probably
redundant, The second checks that withValue uses proper unwind
protection, which doesn't seem to be covered by the test suite yet.
(* ---------------------------------------------------------------- *)
fun test3 (str : string) =
let open MLton.Finalizable
val x = new str
in addFinalizer (x, fn s => print (s ^ ": finalizer\n"));
withValue (x, fn s =>
(print "before GC 5\n";
MLton.GC.collect ();
print "after GC 5\n";
(fn () => (print "invoking touch\n"; touch x))))
end
val _ = (print "before test 5\n";
let val t = test3 "test 5"
in print "before GC 5a\n";
MLton.GC.collect ();
print "after GC 5a\n";
t ();
print "before GC 5b\n";
MLton.GC.collect ();
print "after GC 5b\n"
end;
print "before GC 5c\n";
MLton.GC.collect ();
print "after GC 5c\n")
(* ---------------------------------------------------------------- *)
fun test4 (str : string) =
let open MLton.Finalizable
val x = new str
exception Exit
in addFinalizer (x, fn s => print (s ^ ": finalizer\n"));
withValue (x, fn s =>
(print "before GC 6\n";
MLton.GC.collect ();
print "after GC 6\n";
raise Exit))
handle Exit => ()
end
val _ = (print "before test 6\n";
let val t = test3 "test 6"
in print "before GC 6a\n";
MLton.GC.collect ();
print "after GC 6a\n";
t ();
print "before GC 6b\n";
MLton.GC.collect ();
print "after GC 6b\n"
end;
(* ---------------------------------------------------------------- *)