Summer.Batch.Common.Util.AtomicTypes.AtomicInteger Class Reference

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 int. More...

Inheritance diagram for Summer.Batch.Common.Util.AtomicTypes.AtomicInteger:
Summer.Batch.Common.Util.AtomicTypes.IAtomic< int >

Public Member Functions

 AtomicInteger (int initialValue)
 Creates a new AtomicInteger with a value of initialValue . More...
 
 AtomicInteger ()
 Creates a new AtomicInteger with initial value 0. More...
 
int ReturnValueAndIncrement ()
 Atomically increments by one the current value. More...
 
int ReturnValueAndDecrement ()
 Atomically decrements by one the current value. More...
 
void LazySet (int newValue)
 Eventually sets to the given value. More...
 
int Exchange (int newValue)
 Atomically sets value to newValue and returns the old value. More...
 
bool CompareAndSet (int expectedValue, int newValue)
 Atomically sets the value to newValue if the current value == expectedValue More...
 
virtual bool WeakCompareAndSet (int expectedValue, int newValue)
 Atomically sets the value to newValue if the current value == expectedValue More...
 
int AddDeltaAndReturnPreviousValue (int deltaValue)
 Atomically adds deltaValue to the current value. More...
 
int AddDeltaAndReturnNewValue (int deltaValue)
 Atomically adds deltaValue to the current value. More...
 
int IncrementValueAndReturn ()
 Atomically increments the current value by one. More...
 
int DecrementValueAndReturn ()
 Atomically decrements by one the current value. More...
 
override string ToString ()
 Returns the String representation of the current value. More...
 
- Public Member Functions inherited from Summer.Batch.Common.Util.AtomicTypes.IAtomic< int >
void LazySet (T newValue)
 Eventually sets to the given value. More...
 
bool CompareAndSet (T expectedValue, T newValue)
 Atomically sets the value to the newValue if the current value equals the expectedValue . More...
 
bool WeakCompareAndSet (T expectedValue, T newValue)
 Atomically sets the value to the newValue if the current value equals the expectedValue . May fail spuriously. More...
 
Exchange (T newValue)
 Atomically sets to the given value and returns the previous value. More...
 
string ToString ()
 Returns the String representation of the current value. More...
 

Static Public Member Functions

static implicit operator int (AtomicInteger atomicInteger)
 Implicit converts AtomicInteger to int. More...
 

Properties

int Value [get, set]
 Gets and sets the current value. More...
 
- Properties inherited from Summer.Batch.Common.Util.AtomicTypes.IAtomic< int >
Value [get, set]
 Gets and sets the current value. More...
 

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 int.

Based on the on the back port of JCP JSR-166.

Author
Doug Lea
Griffin Caprio (.NET)
Andreas Doehring (.NET)
Kenneth Xu (Interlocked)

Constructor & Destructor Documentation

Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.AtomicInteger ( int  initialValue)

Creates a new AtomicInteger with a value of initialValue .

Parameters
initialValueThe initial value
Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.AtomicInteger ( )

Creates a new AtomicInteger with initial value 0.

Member Function Documentation

int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.AddDeltaAndReturnNewValue ( int  deltaValue)

Atomically adds deltaValue to the current value.

Parameters
deltaValueThe value to add
Returns
The updated value
int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.AddDeltaAndReturnPreviousValue ( int  deltaValue)

Atomically adds deltaValue to the current value.

Parameters
deltaValueThe value to add
Returns
The previous value
bool Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.CompareAndSet ( int  expectedValue,
int  newValue 
)

Atomically sets the value to newValue if the current value == expectedValue

Parameters
expectedValueThe expected value
newValueThe new value
Returns
true if successful. false return indicates that the actual value was not equal to the expected value.
int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.DecrementValueAndReturn ( )

Atomically decrements by one the current value.

Returns
The updated value
int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.Exchange ( int  newValue)

Atomically sets value to newValue and returns the old value.

Parameters
newValueThe new value
Returns
The previous value
int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.IncrementValueAndReturn ( )

Atomically increments the current value by one.

Returns
The updated value
void Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.LazySet ( int  newValue)

Eventually sets to the given value.

Parameters
newValueThe new value
static implicit Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.operator int ( AtomicInteger  atomicInteger)
static

Implicit converts AtomicInteger to int.

Parameters
atomicIntegerInstance of AtomicInteger.
Returns
The converted int value of atomicInteger .
int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.ReturnValueAndDecrement ( )

Atomically decrements by one the current value.

Returns
The previous value
int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.ReturnValueAndIncrement ( )

Atomically increments by one the current value.

Returns
The previous value
override string Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.ToString ( )

Returns the String representation of the current value.

Returns
The String representation of the current value.
virtual bool Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.WeakCompareAndSet ( int  expectedValue,
int  newValue 
)
virtual

Atomically sets the value to newValue if the current value == expectedValue

Parameters
expectedValueThe expected value
newValueThe new value
Returns
true if successful. false return indicates that the actual value was not equal to the expected value.

Property Documentation

int Summer.Batch.Common.Util.AtomicTypes.AtomicInteger.Value
getset

Gets and sets the current value.

Returns
The current value

The documentation for this class was generated from the following file:
  • Summer.Batch.Common/Util/AtomicTypes/AtomicInteger.cs