Class MessageBuffer

java.lang.Object
org.apache.pekko.util.MessageBuffer

public final class MessageBuffer extends Object
A non thread safe mutable message buffer that can be used to buffer messages inside actors.
  • Constructor Details

    • MessageBuffer

      public MessageBuffer()
  • Method Details

    • empty

      public static MessageBuffer empty()
      Create an empty message buffer.

      Returns:
      an empty message buffer
    • isEmpty

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

      Returns:
      if the buffer is empty
    • nonEmpty

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

      Returns:
      if the buffer is not empty
    • size

      public int size()
      How many elements are in the message buffer.

      Returns:
      the number of elements in the message buffer
    • append

      public MessageBuffer append(Object message, ActorRef ref)
      Add one element to the end of the message buffer.

      Parameters:
      message - the message to buffer
      ref - the actor to buffer
      Returns:
      this message buffer
    • dropHead

      public void dropHead()
      Remove the first element of the message buffer.
    • head

      public scala.Tuple2<Object,ActorRef> head()
      Return the first element of the message buffer.

      Returns:
      the first element or an element containing null if the buffer is empty
    • getHead

      public Pair<Object,ActorRef> getHead()
      Java API

      Return the first element of the message buffer.

      Returns:
      the first element or an element containing null if the buffer is empty
    • foreach

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

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

      public void forEach(Procedure2<Object,ActorRef> f)
      Java API

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

      Parameters:
      f - the function to apply to each element