Class MessageBufferMap<I>

java.lang.Object
org.apache.pekko.util.MessageBufferMap<I>
Type Parameters:
I - (Id type)

public final class MessageBufferMap<I> extends Object
A non thread safe mutable message buffer map that can be used to buffer messages inside actors.

  • Constructor Details

    • MessageBufferMap

      public MessageBufferMap()
  • Method Details

    • add

      public void add(I id)
      Add an id to the buffer map
    • append

      public void append(I id, Object message, ActorRef ref)
      Append an element to the buffer for an id.

      Parameters:
      id - the id to add the element to
      message - the message to buffer
      ref - the actor to buffer
    • contains

      public boolean contains(I id)
      Check if the buffer map contains an id.

      Parameters:
      id - the id to check for
      Returns:
      if the buffer contains the given id
    • drop

      public int drop(I id, String reason, ActorRef deadLetters)
      Remove the buffer for an id, but publish a pekko.actor.Dropped for each dropped buffered message
      Returns:
      how many buffered messages were dropped
    • forEach

      public void forEach(Procedure2<I,MessageBuffer> f)
      Java API

      Iterate over all elements of the buffer map and apply a function to each element.

      Parameters:
      f - the function to apply to each element
    • foreach

      public void foreach(scala.Function2<I,MessageBuffer,scala.runtime.BoxedUnit> f)
      Iterate over all elements of the buffer map and apply a function to each element.

      Parameters:
      f - the function to apply to each element
    • getOrEmpty

      public MessageBuffer getOrEmpty(I id)
      Get the message buffer for an id, or an empty buffer if the id doesn't exist in the map.

      Parameters:
      id - the id to get the message buffer for
      Returns:
      the message buffer for the given id or an empty buffer if the id doesn't exist
    • isEmpty

      public boolean isEmpty()
      Check if the buffer map is empty.

      Returns:
      if the buffer map is empty
    • nonEmpty

      public boolean nonEmpty()
      Check if the buffer map is not empty.

      Returns:
      if the buffer map is not empty
    • remove

      public void remove(I id)
      Remove the buffer for an id.

      Parameters:
      id - the id to remove the buffer for
    • size

      public int size()
      How many ids are in the buffer map.

      Returns:
      the number of ids in the buffer map
    • totalSize

      public int totalSize()
      How many elements are in the buffers in the buffer map.

      Returns:
      the number of elements in the buffers in the buffer map