Package akka.util

Class MessageBuffer


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

      Constructors 
      Constructor Description
      MessageBuffer()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MessageBuffer append​(java.lang.Object message, ActorRef ref)
      Add one element to the end of the message buffer.
      void dropHead()
      Remove the first element of the message buffer.
      static MessageBuffer empty()
      Create an empty message buffer.
      void foreach​(scala.Function2<java.lang.Object,​ActorRef,​scala.runtime.BoxedUnit> f)
      Iterate over all elements of the buffer and apply a function to each element.
      void forEach​(Procedure2<java.lang.Object,​ActorRef> f)
      Java API
      Pair<java.lang.Object,​ActorRef> getHead()
      Java API
      scala.Tuple2<java.lang.Object,​ActorRef> head()
      Return the first element of the message buffer.
      boolean isEmpty()
      Check if the message buffer is empty.
      boolean nonEmpty()
      Check if the message buffer is not empty.
      int size()
      How many elements are in the message buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageBuffer

        public MessageBuffer()
    • Method Detail

      • 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​(java.lang.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<java.lang.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<java.lang.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<java.lang.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<java.lang.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