ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergi Vladykin <sergi.vlady...@gmail.com>
Subject Re: Adding compare-and-set method returning value to distributed atomics
Date Thu, 17 Sep 2015 16:00:32 GMT
Instead of inventing something weird looking I'd better take a closer look
at
what happens in Java 8 and 9.

For example in Java 8 there is already a method AtomicLong.getAndUpdate[1]
(paired
with updateAndGet of course) which provides the needed semantics.
We can implement it reusing known current value if CAS failed.

[1]
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html#getAndUpdate-java.util.function.LongUnaryOperator-

Sergi


2015-09-17 17:20 GMT+03:00 Dmitriy Setrakyan <dsetrakyan@apache.org>:

> On Thu, Sep 17, 2015 at 4:19 PM, Pavel Tupitsyn <ptupitsyn@gridgain.com>
> wrote:
>
> > Hi,
> >
> > Looking at other methods in IgniteAtomicLong, it would be
> > compareAndSetAndGet. Ugly, but consistent.
> >
>
> Agree.
>
>
> >
> > On Thu, Sep 17, 2015 at 3:36 PM, Vladimir Ozerov <vozerov@gridgain.com>
> > wrote:
> >
> > > Igniters,
> > >
> > > As we know Java implementation of atomics are rather limited because it
> > > cannot return current value in case of failed CAS. Other modern
> platforms
> > > like .Net, WinAPI and GCC have this feature.
> > >
> > > We can easily implement this method because we have old value in hands
> > > during distributed CAS. But how to name it?
> > >
> > > - long compareAndSetValue(long, long)?
> > > - compareAndSetReturnValue(long, long)?
> > >
> > > Please share your ideas.
> > >
> > > For examples, GCC goes this way:
> > > __sync_*bool*_compare_and_set
> > > __sync_*val*_compare_and_set
> > >
> > > Vladimir.
> > >
> >
> >
> >
> > --
> > --
> > Pavel Tupitsyn
> > GridGain Systems, Inc.
> > www.gridgain.com
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message