Ja.NET Standard Edition 5.0

Documentation API Specification

Contents

AtomicLongArray Class Reference

Inherits java::io::Serializable.

List of all members.


Detailed Description

A long array in which elements may be updated atomically.

See the java.util.concurrent.atomic package specification for description of the properties of atomic variables.

Since:
1.5
Author:
Doug Lea

Public Member Functions

 AtomicLongArray (int length)
 Create a new AtomicLongArray of given length.
 AtomicLongArray (long[] array)
 Create a new AtomicLongArray with the same length as, and all elements copied from, the given array.
final int length ()
 Returns the length of the array.
final long get (int i)
 Get the current value at position i.
final void set (int i, long newValue)
 Set the element at position i to the given value.
final long getAndSet (int i, long newValue)
 Set the element at position i to the given value and return the old value.
final boolean compareAndSet (int i, long expect, long update)
 Atomically set the value to the given updated value if the current value == the expected value.
final boolean weakCompareAndSet (int i, long expect, long update)
 Atomically set the value to the given updated value if the current value == the expected value.
final long getAndIncrement (int i)
 Atomically increment by one the element at index i.
final long getAndDecrement (int i)
 Atomically decrement by one the element at index i.
final long getAndAdd (int i, long delta)
 Atomically add the given value to element at index i.
final long incrementAndGet (int i)
 Atomically increment the element at index i.
final long decrementAndGet (int i)
 Atomically decrement the element at index i.
long addAndGet (int i, long delta)
 Atomically add the given value to element at index i.
String toString ()
 Returns the String representation of the current values of array.

Private Member Functions

long rawIndex (int i)

Private Attributes

final long[] array

Static Private Attributes

static final long serialVersionUID = -2308431214976778248L
static final Unsafe unsafe = Unsafe.getUnsafe()
static final int base = unsafe.arrayBaseOffset(long[].class)
static final int scale = unsafe.arrayIndexScale(long[].class)

Constructor & Destructor Documentation

AtomicLongArray ( int  length  ) 

Create a new AtomicLongArray of given length.

Parameters:
length the length of the array

AtomicLongArray ( long[]  array  ) 

Create a new AtomicLongArray with the same length as, and all elements copied from, the given array.

Parameters:
array the array to copy elements from
Exceptions:
NullPointerException if array is null


Member Function Documentation

long rawIndex ( int  i  )  [private]

final int length (  ) 

Returns the length of the array.

Returns:
the length of the array

final long get ( int  i  ) 

Get the current value at position i.

Parameters:
i the index
Returns:
the current value

final void set ( int  i,
long  newValue 
)

Set the element at position i to the given value.

Parameters:
i the index
newValue the new value

final long getAndSet ( int  i,
long  newValue 
)

Set the element at position i to the given value and return the old value.

Parameters:
i the index
newValue the new value
Returns:
the previous value

final boolean compareAndSet ( int  i,
long  expect,
long  update 
)

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

Parameters:
i the index
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.

final boolean weakCompareAndSet ( int  i,
long  expect,
long  update 
)

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

May fail spuriously.

Parameters:
i the index
expect the expected value
update the new value
Returns:
true if successful.

final long getAndIncrement ( int  i  ) 

Atomically increment by one the element at index i.

Parameters:
i the index
Returns:
the previous value;

final long getAndDecrement ( int  i  ) 

Atomically decrement by one the element at index i.

Parameters:
i the index
Returns:
the previous value;

final long getAndAdd ( int  i,
long  delta 
)

Atomically add the given value to element at index i.

Parameters:
i the index
delta the value to add
Returns:
the previous value;

final long incrementAndGet ( int  i  ) 

Atomically increment the element at index i.

Parameters:
i the index
Returns:
the updated value;

final long decrementAndGet ( int  i  ) 

Atomically decrement the element at index i.

Parameters:
i the index
Returns:
the updated value;

long addAndGet ( int  i,
long  delta 
)

Atomically add the given value to element at index i.

Parameters:
i the index
delta the value to add
Returns:
the updated value;

String toString (  ) 

Returns the String representation of the current values of array.

Returns:
the String representation of the current values of array.


Member Data Documentation

final long serialVersionUID = -2308431214976778248L [static, private]

final Unsafe unsafe = Unsafe.getUnsafe() [static, private]

final int base = unsafe.arrayBaseOffset(long[].class) [static, private]

final int scale = unsafe.arrayIndexScale(long[].class) [static, private]

final long [] array [private]