public class ConcurrentPackedLongArray extends PackedLongArray
get()
, set()
,
add()
and increment()
operations the logical contents of the array.
ConcurrentPackedLongArray
supports concurrent accumulation, with the add()
and increment()
methods providing lossless atomic accumulation in the presence of
multiple writers. However, it is impotant to note that add()
and increment()
are the *only* safe concurrent operations, and that all other operations, including
get()
, set()
and clear()
may produce "suprising" results if used on an
array that is not at rest.
While the add()
and increment()
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.
Constructor and Description |
---|
ConcurrentPackedLongArray(int virtualLength) |
ConcurrentPackedLongArray(int virtualLength,
int initialPhysicalLength) |
Modifier and Type | Method and Description |
---|---|
void |
add(org.HdrHistogram.packedarray.AbstractPackedLongArray other)
Add the contents of the other array to this one
|
void |
add(int index,
long value)
Add to a value at a virtual index in the array
|
void |
clear()
Clear the array contents
|
ConcurrentPackedLongArray |
copy()
Create a copy of this array, complete with data and everything.
|
boolean |
equals(Object other)
Determine if this array is equivalent to another.
|
long |
get(int index)
Get value at virtual index in the array
|
long |
getEndTimeStamp()
get the end time stamp [optionally] stored with this array
|
int |
getPhysicalLength()
Get the current physical length (in longs) of the array's backing storage
|
long |
getStartTimeStamp()
get the start time stamp [optionally] stored with this array
|
int |
hashCode() |
void |
increment(int index)
Increment value at a virrual index in the array
|
Iterator<Long> |
iterator()
An Iterator over all values in the array
|
int |
length()
Get the (virtual) length of the array
|
Iterable<IterationValue> |
nonZeroValues()
An Iterator over all non-Zero values in the array
|
void |
set(int index,
long value)
Set the value at a virtual index in the array
|
void |
setEndTimeStamp(long timeStampMsec)
Set the end time stamp value associated with this array to a given value.
|
void |
setStartTimeStamp(long timeStampMsec)
Set the start time stamp value associated with this array to a given value.
|
void |
setVirtualLength(int newVirtualArrayLength)
Set a new virtual length for the array.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public ConcurrentPackedLongArray(int virtualLength)
public ConcurrentPackedLongArray(int virtualLength, int initialPhysicalLength)
public void setVirtualLength(int newVirtualArrayLength)
setVirtualLength
in class PackedLongArray
newVirtualArrayLength
- thepublic ConcurrentPackedLongArray copy()
copy
in class PackedLongArray
public String toString()
public void clear()
public long getStartTimeStamp()
public void setStartTimeStamp(long timeStampMsec)
timeStampMsec
- the value to set the time stamp to, [by convention] in msec since the epoch.public long getEndTimeStamp()
public void setEndTimeStamp(long timeStampMsec)
timeStampMsec
- the value to set the time stamp to, [by convention] in msec since the epoch.public long get(int index)
index
- the virtual array indexpublic void increment(int index)
index
- virtual index of value to incrementpublic void add(int index, long value)
index
- the virtual index of the value to be added tovalue
- the value to addpublic void set(int index, long value)
index
- the virtual index of the value to setvalue
- the value to setpublic void add(org.HdrHistogram.packedarray.AbstractPackedLongArray other)
other
- The to add to this arraypublic int getPhysicalLength()
public int length()
public Iterable<IterationValue> nonZeroValues()
public boolean equals(Object other)
Copyright © 2019. All rights reserved.