RFR JDK-8234049: Implementation of Memory Access API (Incubator)
maurizio.cimadamore at oracle.com
Fri Dec 6 08:32:12 UTC 2019
Couple of naming ideas:
> MemorySegment.isAccessible() is a very overloaded term, isOwnByCurrentThread() is maybe better ?
One solution here would be to, instead, have an accessor called
ownerThread() - then clients can test doing ownerThread() !=
Thread.currentThread (or some other thread). After all a segment is
specified to have an owner, so it kind of makes sense to have an
accessor for it?
> I don't understand how MemorySegment.acquire() solve the fact that you have two threads that can access to the same underlying memory area with unprotected access.
> When you own a memory segment, an other thread can acquire a new memory segment and then both thread can mutate the same memory location ?
I believe the name "acquire" might not describe accurately what is going
on - I believe "fork" is much closer to what the method is actually
doing. You can imagine segments forming a tree - if you keep forking
from same segment, you create a lot of sub-segments - and so on and so
forth. A segment cannot be closed if it has a non-zero number of forks.
More information about the core-libs-dev