Hazelcast C++ Client
|
IAtomicLong is a redundant and highly available distributed alternative to the java.util.concurrent.atomic.AtomicLong. More...
#include <IAtomicLong.h>
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 |
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.
int64_t hazelcast::client::IAtomicLong::addAndGet | ( | int64_t | delta | ) |
adds the given value to the current value.
delta | the value to add |
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()));
delta | the value to add |
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.
expect | the expected value |
update | the new value |
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.
expect | the expected value |
update | the new value |
int64_t hazelcast::client::IAtomicLong::decrementAndGet | ( | ) |
decrements the current value by one.
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.
int64_t hazelcast::client::IAtomicLong::get | ( | ) |
Gets the current value.
int64_t hazelcast::client::IAtomicLong::getAndAdd | ( | int64_t | delta | ) |
adds the given value to the current value.
delta | the value to add |
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.
delta | the value to add |
int64_t hazelcast::client::IAtomicLong::getAndIncrement | ( | ) |
increments the current value by one.
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.
int64_t hazelcast::client::IAtomicLong::getAndSet | ( | int64_t | newValue | ) |
sets the given value and returns the old value.
newValue | the new value |
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.
newValue | the new value |
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.
int64_t hazelcast::client::IAtomicLong::incrementAndGet | ( | ) |
increments the current value by one.
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.
void hazelcast::client::IAtomicLong::set | ( | int64_t | newValue | ) |
sets the given value.
newValue | the new value |
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.
newValue | the new value |