Promptly freeing the per-thread cached direct buffers when a thread exits
tprintezis at twitter.com
Fri Apr 6 17:17:41 UTC 2018
Ah, I hadn’t realized that there’s already some tight coupling between
Thread and nio. OK, I’ll just call into sun.nio directly and see what the
reviewers say. :-) Is there a CR for this already? Or should I create one?
Tony Printezis | @TonyPrintezis | tprintezis at twitter.com
On April 6, 2018 at 12:45:29 PM, Alan Bateman (alan.bateman at oracle.com)
On 06/04/2018 15:08, Tony Printezis wrote:
Calling sun.nio directly from java.lang seemed a bit dodgy to me, which is
why I proposed some type of exit hook (maybe I overthought this?). But
that’d be OK, could make this change a lot simpler. :-) And, yes, I came
across the issue of not being able to query whether a ThreadLocal exists on
a Thread when I implemented my prototype. Which is why I think introducing
an exit hook on ThreadLocal, instead of Thread, is probably the better
approach (it will only be called if the ThreadLocal exists).
java.lang.Thread is already tightly connected to blocking I/O operations
(Thread::interrupt for example). In any case, the concern with exposing
exit hooks in the API is that it means running arbitrary code when exiting,
something that would need a lot of consideration before going there.
More information about the core-libs-dev