[Haskell-cafe] HANSEI in Haskell?

Chung-chieh Shan ccshan at cs.rutgers.edu
Fri Feb 25 05:15:11 CET 2011


On 2011-02-24T16:20:46-0600, Antoine Latter wrote:
> On Thu, Feb 24, 2011 at 12:57 PM, Chung-chieh Shan wrote:
> > What
> > we need is a way to tell the garbage collector that the store reference
> > and the cell reference are both needed to access the data so the data
> > can be garbage-collected as soon as *either* the store reference *or
> > the cell reference* is.  (Analogy from the capabilities literature:
> > the key and the lock are both needed to open the door so the door can
> > be garbage-collected as soon as either the key or the lock is.)  Any
> > thoughts on how to achieve that?
> 
> Here's a weak cell which is a candidate for GC as soon as either the
> cell or the key is lost:
> http://hpaste.org/44280/weak_ref_needing_both_halves

That's promising!  The lock I have in mind would probably be a map from
Int to weak pointers.  I'm unfamiliar with System.Mem.Weak so I'll have
to study this code further.  What is "addFinalizer lock (finalize wk)"
for?  It seems wk doesn't have any finalizers to run.

Thanks!

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
1st graffitiist: QUESTION AUTHORITY!
2nd graffitiist: Why?




More information about the Haskell-Cafe mailing list