[concurrency-interest] DirectByteBuffers and reachabilityFence

Vitaly Davidovich vitalyd at gmail.com
Wed Dec 9 14:20:07 EST 2015

I don't see how this extends the lifetime of the object unless, at minimum,
you increment the counter at each operation where you want to extend the
lifetime.  And at this point, you may as well just stick
reachabilityFence(this) inside the finalizer then.

On Wed, Dec 9, 2015 at 2:03 PM, Andrew Haley <aph at redhat.com> wrote:

> On 12/09/2015 06:52 PM, Vitaly Davidovich wrote:
> >>
> >> I don't think it'd be measurable.  A global volatile write is pretty
> >> cheap.  And I'm sure there are several such writes when queuing a
> >> finalizer.
> >
> >
> >> The global volatile gets hit once, when the object is finalized.  Not
> >> at every access, which is what you'd have to do with a compiler
> >> barrier.
> >
> > Perhaps I misunderstood your global volatile suggestion -- when is it
> > written to exactly? What's the usage?
> In the finalizer.  The idea is that you keep a counter in the
> object and then write it to a global when finalized.  I don't
> think this can be done much more cheaply without changes to
> the compiler, and it's certainly much cheaper than the current
> implementation of reachabilityFence.
> Andrew.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151209/6174f03a/attachment.html>

More information about the Concurrency-interest mailing list