[foreign-memaccess] RFR: Move "owner" field and thread-confinement checks to MemoryScope

Peter Levart plevart at openjdk.java.net
Fri May 15 09:01:42 UTC 2020

Now MemoryScope is simplified, I re-based this change and am opening this PR on top. Currently MemorySegment is
encapsulating thread-confinement logic and state (owner field) while MemoryScope is encapsulating temporal-confinement
logic and state. But the interplay between the two must be very carefully caried out (for example, close() or dup() on
child scopes may only be called in owner thread). By moving the thread-confinement logic and state to MemoryScope, I
think we get better encapsulation as all MemoryScope methods become "safe" - some can still be called in owner thread
only, but failing to do so throws IllegalSateException instead of exhibiting undefined behavior.


Commit messages:
 - Move "owner" field and thread-confinement checks from MemorySegment to MemoryScope

Changes: https://git.openjdk.java.net/panama-foreign/pull/167/files
 Webrev: https://webrevs.openjdk.java.net/panama-foreign/167/webrev.00
  Stats: 179 lines in 5 files changed: 84 ins; 14 del; 81 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/167.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/167/head:pull/167

PR: https://git.openjdk.java.net/panama-foreign/pull/167

More information about the panama-dev mailing list