Robert Roessler wrote:
It seems like it could be useful. It isn't possible to run ML code while
actually doing the garbage-collection so it would be necessary to record
that a vol was due to be deleted and then call the finaliser at some
point later on. That, of course, raises the question of which thread
runs the finaliser. From a bit of searching it appears that in Java
finalisers can be run on any thread which doesn't seem a good idea.
It may be possible to get the effect by using a weak reference
(structure Weak). That requires a thread to monitor Weak.weakSignal and
use that to then check which values have been deleted.
Probably because I already had a solution for this in my head (from what
OCaml does), I wasn't clear...
The finalizer is intended to be *foreign* code, presumably C - and it is
*never* able to do anying which affects the Poly heap(s). This is not
as restrictive as it may sound, since the idea of the finalizer (as
discussed here, anyway) is to manage the extra-Poly environment in any
case.
I will look at this (in foreign.cpp?)... I will of course check the
volatile implementation again, but aren't they handled specially WRT
Poly saved state? As in, they do NOT persist?
The term "vol" was introduced in the days when Poly/ML had a persistent
store and the idea was that these were values that could not be saved
into the store. The concept is still there: it's possible to save the
ML object into a saved state but any attempt to use it another session
will raise an exception.
That would be ideal, as the changes to support the foreign finalizer
would be more contained... basically just an extra field per volatile
value (or something like that), and API to set/get its value.
That was how I saw it when you described it.
And the GC code to call the foreign function when the volatile is about
to be reclaimed. ;)
I was thinking that this would be an ML function (which might call a C
function) but if it's a C function then it could indeed be called during
the GC. In that case the get/set functions return/take a "vol" to
denote the finaliser and adding it wouldn't be too difficult.
David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml