On 10/2/2017 2:52 PM, Matthew Flatt wrote:
If we change `ffi/unsafe/alloc` so that a custodian shutdown runs all
deallocators, that would work in many cases. It would create a problem,
however, if there are objects to deallocate where the deallocation
function references other objects that themselves must be deallocated.
That is, an allocated value A might depend on an allocated value B up
until the point that A has been deallocated. That dependency can be
expressed to `ffi/unsafe/alloc` (via the garbage collector) by
including a reference to B in the deallocation closure for A. Setting
up dependencies that way is not common, but I'm pretty sure I've used
that pattern once or twice. Meanwhile, there's no similar way to order
callbacks that are registered with a custodian.


IIRC, the JVM executes finalizers in reverse order of registration - expecting that, in your example, A would have been allocated before B.  Is that something that would work here? [He asks naively.]

I'm tempted to say that `ffi/unsafe/alloc` should only be used for
objects where the deallocation order doesn't matter, so that
deallocators can be triggered by a custodian shutdown. But an
additional constraint is needed: values to be deallocated cannot be
used by any other custodian-shutdown callbacks. That additional
constraint seems too limiting.

Maybe we need to add some sort of ordering constraints to custodians,
but I'm not immediately sure of the right way to do that.

George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to