Class Accumulator<E>

java.lang.Object
org.apache.cassandra.utils.concurrent.Accumulator<E>
Type Parameters:
E -

public class Accumulator<E> extends Object
A simple append-only collection supporting an unbounded number of concurrent readers/writers, but a bounded number of items.
  • Constructor Details

    • Accumulator

      public Accumulator(int size)
  • Method Details

    • 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 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 with add(Object).