Class ConcurrentPackedLongArray
- java.lang.Object
-
- org.HdrHistogram.packedarray.AbstractPackedLongArray
-
- org.HdrHistogram.packedarray.PackedLongArray
-
- org.HdrHistogram.packedarray.ConcurrentPackedLongArray
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<java.lang.Long>
- Direct Known Subclasses:
PackedArrayRecorder.InternalConcurrentPackedLongArray
public class ConcurrentPackedLongArray extends PackedLongArray
A Packed array of signed 64 bit values that supportsget()
,set()
,add()
andincrement()
operations the logical contents of the array.ConcurrentPackedLongArray
supports concurrent accumulation, with theadd()
andincrement()
methods providing lossless atomic accumulation in the presence of multiple writers. However, it is impotant to note thatadd()
andincrement()
are the *only* safe concurrent operations, and that all other operations, includingget()
,set()
andclear()
may produce "suprising" results if used on an array that is not at rest. While theadd()
andincrement()
methods are not quite wait-free, they come "close" that behvaior in the sense that a given thread will incur a total of no more than a capped fixed number (e.g. 74 in a current implementation) of non-wait-free add or increment operations during the lifetime of an array, regradless of the number of operations done.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.HdrHistogram.packedarray.AbstractPackedLongArray
AbstractPackedLongArray.AllValuesIterator
-
-
Field Summary
Fields Modifier and Type Field Description (package private) WriterReaderPhaser
wrp
-
Fields inherited from class org.HdrHistogram.packedarray.AbstractPackedLongArray
NUMBER_OF_NON_ZEROS_TO_HASH
-
-
Constructor Summary
Constructors Constructor Description ConcurrentPackedLongArray(int virtualLength)
ConcurrentPackedLongArray(int virtualLength, int initialPhysicalLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the array contents(package private) void
clearContents()
ConcurrentPackedLongArray
copy()
Create a copy of this array, complete with data and everything.(package private) long
criticalSectionEnter()
(package private) void
criticalSectionExit(long criticalValueAtEnter)
private void
readObject(java.io.ObjectInputStream o)
(package private) void
resizeStorageArray(int newPhysicalLengthInLongs)
void
setVirtualLength(int newVirtualArrayLength)
Set a new virtual length for the array.java.lang.String
toString()
-
Methods inherited from class org.HdrHistogram.packedarray.AbstractPackedLongArray
add, add, equals, get, getArrayContext, getEndTimeStamp, getPhysicalLength, getStartTimeStamp, hashCode, increment, iterator, length, nonZeroValues, set, setArrayContext, setEndTimeStamp, setStartTimeStamp
-
-
-
-
Field Detail
-
wrp
transient WriterReaderPhaser wrp
-
-
Method Detail
-
resizeStorageArray
void resizeStorageArray(int newPhysicalLengthInLongs)
- Overrides:
resizeStorageArray
in classPackedLongArray
-
setVirtualLength
public void setVirtualLength(int newVirtualArrayLength)
Description copied from class:AbstractPackedLongArray
Set a new virtual length for the array.- Overrides:
setVirtualLength
in classPackedLongArray
- Parameters:
newVirtualArrayLength
- the
-
copy
public ConcurrentPackedLongArray copy()
Description copied from class:AbstractPackedLongArray
Create a copy of this array, complete with data and everything.- Overrides:
copy
in classPackedLongArray
- Returns:
- A distinct copy of this array.
-
clearContents
void clearContents()
- Overrides:
clearContents
in classPackedLongArray
-
criticalSectionEnter
long criticalSectionEnter()
- Overrides:
criticalSectionEnter
in classPackedLongArray
-
criticalSectionExit
void criticalSectionExit(long criticalValueAtEnter)
- Overrides:
criticalSectionExit
in classPackedLongArray
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractPackedLongArray
-
clear
public void clear()
Description copied from class:AbstractPackedLongArray
Clear the array contents- Overrides:
clear
in classAbstractPackedLongArray
-
readObject
private void readObject(java.io.ObjectInputStream o) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-