[MLton-devel] finalization

Matthew Fluet fluet@cs.cornell.edu
Fri, 9 May 2003 16:04:23 -0400 (EDT)


> Adding  one  (simple  I  think)  primitive  to  MLton  would make the current
> experimental implementation of weak's give you something very very  close  to
> finalization.  The one new primitive would be
>     val waitForGC: unit -> unit
> Calling this function simply waits until a GC is done and then returns.

I like the idea, but I don't think that would push too much scheduling
into the garbage collector.  I think the more primitive notion would be
the following:
  val afterGC: (unit -> unit) -> unit
which mimics Handler.handleWith and FFI.handleCallFromC (i.e., that the GC
knows about it and switches to the installed thread at the appropriate
time).  Obviously there is some tickery with GCing while in the afterGC
function, but presumably that can be taken care of by having a primitive
  val installAfterGC: (unit -> unit) -> unit
make the semantics such that the installed function is uninstalled after
each GC (i.e., just before the switch) and then implementing
  fun afterGC f =
    let val f' = fn () => (f (); installAfterGC f)
    in installAfterGC f
    end
although that has the problem that the you can't change the installed GC
handler from within the GC handler (which presumably is one place where
you'd like to do so).

Anyways, there are a couple of details to work out, but I really like the
idea.




-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com

_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel