activemq-cpp-3.6.0
decaf::util::concurrent::atomic::AtomicInteger Class Reference

An int value that may be updated atomically. More...

#include <src/main/decaf/util/concurrent/atomic/AtomicInteger.h>

Inheritance diagram for decaf::util::concurrent::atomic::AtomicInteger:

Public Member Functions

 AtomicInteger ()
 Create a new AtomicInteger with an initial value of 0.
 AtomicInteger (int initialValue)
 Create a new AtomicInteger with the given initial value.
virtual ~AtomicInteger ()
int get () const
 Gets the current value.
void set (int newValue)
 Sets to the given value.
int getAndSet (int newValue)
 Atomically sets to the given value and returns the old value.
bool compareAndSet (int expect, int update)
 Atomically sets the value to the given updated value if the current value == the expected value.
int getAndIncrement ()
 Atomically increments by one the current value.
int getAndDecrement ()
 Atomically decrements by one the current value.
int getAndAdd (int delta)
 Atomically adds the given value to the current value.
int incrementAndGet ()
 Atomically increments by one the current value.
int decrementAndGet ()
 Atomically decrements by one the current value.
int addAndGet (int delta)
 Atomically adds the given value to the current value.
std::string toString () const
 Returns the String representation of the current value.
int intValue () const
 Description copied from class: Number Returns the value of the specified number as an int.
long long longValue () const
 Description copied from class: Number Returns the value of the specified number as a long.
float floatValue () const
 Description copied from class: Number Returns the value of the specified number as a float.
double doubleValue () const
 Description copied from class: Number Returns the value of the specified number as a double.
- Public Member Functions inherited from decaf::lang::Number
virtual ~Number ()
virtual unsigned char byteValue () const
 Answers the byte value which the receiver represents.
virtual short shortValue () const
 Answers the short value which the receiver represents.

Detailed Description

An int value that may be updated atomically.

An AtomicInteger is used in applications such as atomically incremented counters, and cannot be used as a replacement for an Integer. However, this class does extend Number to allow uniform access by tools and utilities that deal with numerically-based classes.

Constructor & Destructor Documentation

decaf::util::concurrent::atomic::AtomicInteger::AtomicInteger ( )

Create a new AtomicInteger with an initial value of 0.

decaf::util::concurrent::atomic::AtomicInteger::AtomicInteger ( int  initialValue)

Create a new AtomicInteger with the given initial value.

Parameters
initialValue- The initial value of this object.
virtual decaf::util::concurrent::atomic::AtomicInteger::~AtomicInteger ( )
inlinevirtual

Member Function Documentation

int decaf::util::concurrent::atomic::AtomicInteger::addAndGet ( int  delta)

Atomically adds the given value to the current value.

Parameters
delta- the value to add.
Returns
the updated value.
bool decaf::util::concurrent::atomic::AtomicInteger::compareAndSet ( int  expect,
int  update 
)

Atomically sets the value to the given updated value if the current value == the expected value.

Parameters
expect- the expected value
update- the new value
Returns
true if successful. False return indicates that the actual value was not equal to the expected value.
int decaf::util::concurrent::atomic::AtomicInteger::decrementAndGet ( )

Atomically decrements by one the current value.

Returns
the updated value.

Referenced by decaf::util::concurrent::atomic::AtomicRefCounter::release().

double decaf::util::concurrent::atomic::AtomicInteger::doubleValue ( ) const
virtual

Description copied from class: Number Returns the value of the specified number as a double.

This may involve rounding.

Returns
the numeric value represented by this object after conversion to type double.

Implements decaf::lang::Number.

float decaf::util::concurrent::atomic::AtomicInteger::floatValue ( ) const
virtual

Description copied from class: Number Returns the value of the specified number as a float.

This may involve rounding.

Returns
the numeric value represented by this object after conversion to type float.

Implements decaf::lang::Number.

int decaf::util::concurrent::atomic::AtomicInteger::getAndAdd ( int  delta)

Atomically adds the given value to the current value.

Parameters
delta- The value to add.
Returns
the previous value.

Referenced by decaf::util::concurrent::LinkedBlockingQueue< Pointer< Transport > >::drainTo().

int decaf::util::concurrent::atomic::AtomicInteger::getAndDecrement ( )
int decaf::util::concurrent::atomic::AtomicInteger::getAndIncrement ( )
int decaf::util::concurrent::atomic::AtomicInteger::getAndSet ( int  newValue)

Atomically sets to the given value and returns the old value.

Parameters
newValue- the new value.
Returns
the previous value.

Referenced by decaf::util::concurrent::LinkedBlockingQueue< Pointer< Transport > >::clear().

int decaf::util::concurrent::atomic::AtomicInteger::incrementAndGet ( )

Atomically increments by one the current value.

Returns
the updated value.

Referenced by decaf::util::concurrent::atomic::AtomicRefCounter::AtomicRefCounter().

int decaf::util::concurrent::atomic::AtomicInteger::intValue ( ) const
virtual

Description copied from class: Number Returns the value of the specified number as an int.

This may involve rounding or truncation.

Returns
the numeric value represented by this object after conversion to type int.

Implements decaf::lang::Number.

long long decaf::util::concurrent::atomic::AtomicInteger::longValue ( ) const
virtual

Description copied from class: Number Returns the value of the specified number as a long.

This may involve rounding or truncation.

Returns
the numeric value represented by this object after conversion to type long long.

Implements decaf::lang::Number.

void decaf::util::concurrent::atomic::AtomicInteger::set ( int  newValue)
inline

Sets to the given value.

Parameters
newValue- the new value

Referenced by decaf::util::concurrent::LinkedBlockingQueue< Pointer< Transport > >::clear().

std::string decaf::util::concurrent::atomic::AtomicInteger::toString ( ) const

Returns the String representation of the current value.

Returns
the String representation of the current value.

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