RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more

Martin Buchholz martinrb at google.com
Mon May 9 19:01:12 UTC 2016


On Mon, May 9, 2016 at 11:10 AM, Roger Riggs <Roger.Riggs at oracle.com> wrote:
> I'm not sure I understand what
>
> "a CompletableFuture-based API for cleanup actions."
>
> would look like or how it would be used.

I'm fuzzy myself, but the idea is that any asynchronous action that
will be completed in the future should be represented by a
CompletableFuture.  In this case, the asynchronous actions are
performed by the GC.  I imagine an API on e.g. WeakReference

CompletableFuture<Void> whenCleared()

and then a user can schedule follow-on actions in the executor of their choice.

WeakReference r = ...
r.whenCleared().thenRunAsync(...)

One idea is to throw away as much Cleaner machinery as possible to
reuse CompletableFuture machinery.  Or build on top...  All
concurrency machinery is hard for humans to understand.



More information about the core-libs-dev mailing list