RFR: 8351565: Implement JEP 502: Stable Values (Preview)
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Mar 19 16:20:21 UTC 2025
On Sun, 16 Mar 2025 03:30:46 GMT, John Rose <john.r.rose at oracle.com> wrote:
> This might seem to contradict my previous assertion
> that StableValue, being mutex based, must not
> use lock-free idioms. That comment applies
> specifically to the update operation that takes
> a lambda. Other operations, such as reading
> a SV, or hopefully poking a value at a SV can be,
> and should be, composed of lock-free operations.
> Why take a lock when it?s just a one-word read
> or write?
The important thing is that the lambda-accepting operation uses a mutex, so that the lambda (which might be a potentially expensive operation) is only invoked once.
While other operations might in principle be lock-free, I'm not completely against pushing a very simple first iteration that is clearly and obviously correct. Once all the tests etc. are in place, it should be possible to improve the implementation further and remove locking where we can? (I think the interplay between the lambda-accepting set and a regular set will make it a bit tricky to go partially lock free)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23972#issuecomment-2737258754
More information about the core-libs-dev
mailing list