Package akka.util

Class MessageBufferMap<I>

  • Type Parameters:
    I - (Id type)

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

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(I id)
      Add an id to the buffer map
      void append​(I id, java.lang.Object message, ActorRef ref)
      Append an element to the buffer for an id.
      boolean contains​(I id)
      Check if the buffer map contains an id.
      int drop​(I id, java.lang.String reason, ActorRef deadLetters)
      Remove the buffer for an id, but publish a Dropped for each dropped buffered message
      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.
      void forEach​(Procedure2<I,​MessageBuffer> f)
      Java API
      MessageBuffer getOrEmpty​(I id)
      Get the message buffer for an id, or an empty buffer if the id doesn't exist in the map.
      boolean isEmpty()
      Check if the buffer map is empty.
      boolean nonEmpty()
      Check if the buffer map is not empty.
      void remove​(I id)
      Remove the buffer for an id.
      int size()
      How many ids are in the buffer map.
      int totalSize()
      How many elements are in the buffers in the buffer map.
      • Methods inherited from class java.lang.Object

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

      • MessageBufferMap

        public MessageBufferMap()
    • Method Detail

      • add

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

        public void append​(I id,
                           java.lang.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,
                        java.lang.String reason,
                        ActorRef deadLetters)
        Remove the buffer for an id, but publish a 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