[MLton] adding synchronous finalizers

Henry Cejtin henry@sourcelight.com
Fri, 1 Oct 2004 22:21:17 -0500


Ok,  I'm  definitely  confused now.  Suppose a finalizer runs when we are not
synchronous, but sets the synchronous flag to true?

If it really is true that there are two finalizer lists, with ones  from  the
first  being  added  to the second when the objects are ready to finalize and
when synchronous is false (or polling is being done), then I guess that  this
isn't  an  issue,  but  it  is semantically different in that a finalizer not
currently running will start to run later asynchronously.

As to the second point, my claim is that running  finalizers  might  be  very
expensive,  but  I  don't mind because they are only run on explicit polls or
when a GC happens (in the  non-synchronous  case).   Your  code  always  runs
finalizers  when I switch from non-synchronous to synchronous mode.  Consider
the case of code that jumps between modes very often.  I don't want  that  to
cause finalizers to run more frequently.

Given  that  you only discover that a finalizer should run when a GC happens,
maybe this doesn't really matter much, but I still don't see  any  reason  to
force finalizers to run at that point.

I guess I'm still confused about how your code works.