Class SequenceGroup


public final class SequenceGroup extends Sequence
A Sequence group that can dynamically have Sequences added and removed while being thread safe.

The get() and set(long) methods are lock free and can be concurrently be called with the add(Sequence) and remove(Sequence).

  • Field Details

  • Constructor Details

    • SequenceGroup

      public SequenceGroup()
      Default Constructor
  • Method Details

    • get

      public long get()
      Get the minimum sequence value for the group.
      Overrides:
      get in class Sequence
      Returns:
      the minimum sequence value for the group.
    • set

      public void set(long value)
      Set all Sequences in the group to a given value.
      Overrides:
      set in class Sequence
      Parameters:
      value - to set the group of sequences to.
    • add

      public void add(Sequence sequence)
      Add a Sequence into this aggregate. This should only be used during initialisation. Use addWhileRunning(Cursored, Sequence)
      Parameters:
      sequence - to be added to the aggregate.
      See Also:
    • remove

      public boolean remove(Sequence sequence)
      Remove the first occurrence of the Sequence from this aggregate.
      Parameters:
      sequence - to be removed from this aggregate.
      Returns:
      true if the sequence was removed otherwise false.
    • size

      public int size()
      Get the size of the group.
      Returns:
      the size of the group.
    • addWhileRunning

      public void addWhileRunning(Cursored cursored, Sequence sequence)
      Adds a sequence to the sequence group after threads have started to publish to the Disruptor. It will set the sequences to cursor value of the ringBuffer just after adding them. This should prevent any nasty rewind/wrapping effects.
      Parameters:
      cursored - The data structure that the owner of this sequence group will be pulling it's events from.
      sequence - The sequence to add.