Thread safety check of MemorySegment

Johannes Lichtenberger lichtenberger.johannes at gmail.com
Tue Jul 21 23:44:44 UTC 2020


So, it likely will not be part of Java 15, right?

I'm running into the same problem, when I'm sharing a transaction (only one
thread ever accesses it) with another thread and the other thread closes
the transaction. Same problem with the segment close()-method.

kind regards
Johannes

Am Mi., 22. Juli 2020 um 01:24 Uhr schrieb Maurizio Cimadamore <
maurizio.cimadamore at oracle.com>:

>
> On 21/07/2020 22:51, NekoCaffeine wrote:
> >> https://gist.github.com/mcimadamore/128ee904157bb6c729a10596e69edffd
> > This is a great example.
> >
> >> The *right* solution from an API perspective is to find a way to
> disable confinement in a way that works
> > I very much agree with this point, which is exactly what I want to
> express.
> >
> > So from a design rather than implementation perspective, should I expect
> a new way to disable thread checking or should I use CustomMappedSegment?
>
> So the crux of the issue here is that there's no Runnable that will
> unmap a given mapped address. But such a Runnable can be implemented in
> several ways:
>
> * with plain JNI
> * using the ForeignLinker API (although that is not part of JDK 15 - but
> is available in the Panama repo)
> * going all in and re-implement mapped segment (similar to what I've
> done with CustomMappedSegment)
>
> I think from an API perspective, if we manage to solve the confinement
> problem, then I expect the memory segment API will have an extra method
> to either turn a confined segment into an unconfined one, or vice-versa.
> So you will be able to just create your mapped segment using mapFromPath
> and then just 'share' it (and make it unconfined).
>
> Hope this helps.
>
> Maurizio
>
> >
> > Thanks,
> >
> > NekoCaffeine
>


More information about the panama-dev mailing list