Draft JEP on enhanced volatiles

Martin Buchholz martinrb at google.com
Sat Feb 8 01:21:17 UTC 2014


On Fri, Feb 7, 2014 at 4:49 PM, Doug Lea <dl at cs.oswego.edu> wrote:

>
>  As a limitation, I'd call out that its not obvious how this would scale to
>> DCAS.
>>
>
> Right; thanks. Although the issues vary depending on whether
> you are dealing with the double-width sense of DCAS (side-by-side
> fields of the same object; possibly some sort of "wide" value type)
> versus "2CAS" (2 separate vars, a form of transaction). My current
> thinking about 2CAS is that for the sake of portable implementation,
> we would need to restrict the classes of objects that are 2CASable,
> so wouldn't be addressed by this JEP. But some new wide value
> type X, if ever supported, could be accommodated by creating a
> VolatileX class and using the same rules as for other cases. We'd
> want to spec this in a way that make such things is possible.


I rather like what C++11 did with atomic<TYPE> - it accepts any size TYPE,
and falls back to locking if the TYPE is too large, and the programmer can
query at compile time whether native atomic access is possible for that
TYPE.
If we get value types, it will be natural to do

complex z;
z.volatile.compareAndSet ...

I think "wide" 2-CAS is completely separate from transactional 2-CAS.  The
former isn't really a 2-CAS at all; just a wide single-CAS.



More information about the core-libs-dev mailing list