Class Accumulator<E>
- java.lang.Object
-
- org.apache.cassandra.utils.concurrent.Accumulator<E>
-
- Type Parameters:
E-
public class Accumulator<E> extends java.lang.ObjectA simple append-only collection supporting an unbounded number of concurrent readers/writers, but a bounded number of items.
-
-
Constructor Summary
Constructors Constructor Description Accumulator(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(E item)Adds an item to the collection.intcapacity()voidclearUnsafe(int i)Removes element at the speficied index from this accumulator.Eget(int i)booleanisEmpty()intsize()java.util.Collection<E>snapshot()
-
-
-
Method Detail
-
add
public void add(E item)
Adds an item to the collection. Note it is not guaranteed to be visible on exiting the method, if another add was happening concurrently; it will be visible once all concurrent adds (which are non-blocking) complete, but it is not guaranteed that any size change occurs during the execution of any specific call.- Parameters:
item- add to collection
-
isEmpty
public boolean isEmpty()
-
size
public int size()
- Returns:
- the size of guaranteed-to-be-visible portion of the list
-
capacity
public int capacity()
-
get
public E get(int i)
-
snapshot
public java.util.Collection<E> snapshot()
-
clearUnsafe
public void clearUnsafe(int i)
Removes element at the speficied index from this accumulator. This method is not thread-safe when used concurrently withadd(Object).
-
-