Hazelcast C++ Client
Public Member Functions | Friends | List of all members
hazelcast::client::IAtomicLong Class Reference

IAtomicLong is a redundant and highly available distributed alternative to the java.util.concurrent.atomic.AtomicLong. More...

#include <IAtomicLong.h>

+ Inheritance diagram for hazelcast::client::IAtomicLong:

Public Member Functions

int64_t addAndGet (int64_t delta)
 adds the given value to the current value. More...
 
bool compareAndSet (int64_t expect, int64_t update)
 sets the value to the given updated value only if the current value is equal to the expected value. More...
 
int64_t decrementAndGet ()
 decrements the current value by one. More...
 
int64_t get ()
 Gets the current value. More...
 
int64_t getAndAdd (int64_t delta)
 adds the given value to the current value. More...
 
int64_t getAndSet (int64_t newValue)
 sets the given value and returns the old value. More...
 
int64_t incrementAndGet ()
 increments the current value by one. More...
 
int64_t getAndIncrement ()
 increments the current value by one. More...
 
void set (int64_t newValue)
 sets the given value. More...
 
virtual const std::string & getServiceName () const
 
virtual const std::string & getName () const
 
virtual void destroy ()
 
boost::shared_ptr< ICompletableFuture< int64_t > > addAndGetAsync (int64_t delta)
 Atomically adds the given value to the current value. More...
 
boost::shared_ptr< ICompletableFuture< bool > > compareAndSetAsync (int64_t expect, int64_t update)
 Atomically sets the value to the given updated value only if the current value. More...
 
boost::shared_ptr< ICompletableFuture< int64_t > > decrementAndGetAsync ()
 Atomically decrements the current value by one. More...
 
boost::shared_ptr< ICompletableFuture< int64_t > > getAsync ()
 Gets the current value. More...
 
boost::shared_ptr< ICompletableFuture< int64_t > > getAndAddAsync (int64_t delta)
 Atomically adds the given value to the current value. More...
 
boost::shared_ptr< ICompletableFuture< int64_t > > getAndSetAsync (int64_t newValue)
 Atomically sets the given value and returns the old value. More...
 
boost::shared_ptr< ICompletableFuture< int64_t > > incrementAndGetAsync ()
 Atomically increments the current value by one. More...
 
boost::shared_ptr< ICompletableFuture< int64_t > > getAndIncrementAsync ()
 Atomically increments the current value by one. More...
 
boost::shared_ptr< ICompletableFuture< void > > setAsync (int64_t newValue)
 Atomically sets the given value. More...
 

Friends

class impl::HazelcastClientInstanceImpl
 

Detailed Description

IAtomicLong is a redundant and highly available distributed alternative to the java.util.concurrent.atomic.AtomicLong.

Asynchronous variants of all methods have been introduced in Hazelcast version 3.7. Async methods return immediately an ICompletableFuture from which the operation's result can be obtained either in a blocking manner or by registering a callback to be executed upon completion. For example:


boost::shared_ptr<ICompletableFuture<int64_t> > future = atomicLong.addAndGetAsync(13);
future->andThen(boost::shared_ptr<ExecutionCallback<V> >(new  MyExecutionCallback()));

During a network partition event it is possible for the IAtomicLong to exist in each of the partitioned clusters or to not exist at all. Under these circumstances the values held in the IAtomicLong may diverge. Once the network partition heals, Hazelcast will use the configured split-brain merge policy to resolve conflicting values.

Supports Quorum since 3.10 in cluster versions 3.10 and higher.

Member Function Documentation

◆ addAndGet()

int64_t hazelcast::client::IAtomicLong::addAndGet ( int64_t  delta)

adds the given value to the current value.

Parameters
deltathe value to add
Returns
the updated value

◆ addAndGetAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::addAndGetAsync ( int64_t  delta)

Atomically adds the given value to the current value.

This method will dispatch a request and return immediately an ICompletableFuture.

The operations result can be obtained in a blocking way, or a callback can be provided for execution upon completion, as demonstrated in the following examples:


boost::shared_ptr<ICompletableFuture<int64_t> > future = atomicLong.addAndGetAsync(13);
// do something else, then read the result
// this method will block until the result is available
int64_t result = future.get();

  future->andThen(boost::shared_ptr<ExecutionCallback<V> >(new  MyExecutionCallback()));
Parameters
deltathe value to add
Returns
an ICompletableFuture bearing the response
Since
cluster version 3.7

◆ compareAndSet()

bool hazelcast::client::IAtomicLong::compareAndSet ( int64_t  expect,
int64_t  update 
)

sets the value to the given updated value only if the current value is equal to the expected value.

Parameters
expectthe expected value
updatethe new value
Returns
true if successful; or false if the actual value was not equal to the expected value.

◆ compareAndSetAsync()

boost::shared_ptr< ICompletableFuture< bool > > hazelcast::client::IAtomicLong::compareAndSetAsync ( int64_t  expect,
int64_t  update 
)

Atomically sets the value to the given updated value only if the current value.

==

the expected value.

This method will dispatch a request and return immediately an ICompletableFuture.

Parameters
expectthe expected value
updatethe new value
Returns
an ICompletableFuture with value
true
if successful; or
false
if the actual value was not equal to the expected value
Since
cluster version 3.7

◆ decrementAndGet()

int64_t hazelcast::client::IAtomicLong::decrementAndGet ( )

decrements the current value by one.

Returns
the updated value

◆ decrementAndGetAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::decrementAndGetAsync ( )

Atomically decrements the current value by one.

This method will dispatch a request and return immediately an ICompletableFuture.

Returns
an ICompletableFuture with the updated value
Since
cluster version 3.7

◆ get()

int64_t hazelcast::client::IAtomicLong::get ( )

Gets the current value.

Returns
the current value

◆ getAndAdd()

int64_t hazelcast::client::IAtomicLong::getAndAdd ( int64_t  delta)

adds the given value to the current value.

Parameters
deltathe value to add
Returns
the old value before the add

◆ getAndAddAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::getAndAddAsync ( int64_t  delta)

Atomically adds the given value to the current value.

This method will dispatch a request and return immediately an ICompletableFuture.

Parameters
deltathe value to add
Returns
an ICompletableFuture with the old value before the addition
Since
cluster version 3.7

◆ getAndIncrement()

int64_t hazelcast::client::IAtomicLong::getAndIncrement ( )

increments the current value by one.

Returns
the old value

◆ getAndIncrementAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::getAndIncrementAsync ( )

Atomically increments the current value by one.

This method will dispatch a request and return immediately an ICompletableFuture.

Returns
an ICompletableFuture with the old value
Since
cluster version 3.7

◆ getAndSet()

int64_t hazelcast::client::IAtomicLong::getAndSet ( int64_t  newValue)

sets the given value and returns the old value.

Parameters
newValuethe new value
Returns
the old value

◆ getAndSetAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::getAndSetAsync ( int64_t  newValue)

Atomically sets the given value and returns the old value.

This method will dispatch a request and return immediately an ICompletableFuture.

Parameters
newValuethe new value
Returns
an ICompletableFuture with the old value
Since
cluster version 3.7

◆ getAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::getAsync ( )

Gets the current value.

This method will dispatch a request and return immediately an ICompletableFuture.

Returns
an ICompletableFuture with the current value
Since
cluster version 3.7

◆ incrementAndGet()

int64_t hazelcast::client::IAtomicLong::incrementAndGet ( )

increments the current value by one.

Returns
the updated value

◆ incrementAndGetAsync()

boost::shared_ptr< ICompletableFuture< int64_t > > hazelcast::client::IAtomicLong::incrementAndGetAsync ( )

Atomically increments the current value by one.

This method will dispatch a request and return immediately an ICompletableFuture.

Returns
an ICompletableFuture with the updated value
Since
cluster version 3.7

◆ set()

void hazelcast::client::IAtomicLong::set ( int64_t  newValue)

sets the given value.

Parameters
newValuethe new value

◆ setAsync()

boost::shared_ptr< ICompletableFuture< void > > hazelcast::client::IAtomicLong::setAsync ( int64_t  newValue)

Atomically sets the given value.

This method will dispatch a request and return immediately an ICompletableFuture.

Parameters
newValuethe new value
Returns
an ICompletableFuture
Since
cluster version 3.7

The documentation for this class was generated from the following files: