Class StashBufferImpl<T>

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> StashBufferImpl<T> apply​(int capacity)  
      int capacity()  
      void foreach​(scala.Function1<T,​scala.runtime.BoxedUnit> f)
      Iterate over all elements of the buffer and apply a function to each element, without removing them.
      void forEach​(java.util.function.Consumer<T> f)
      Iterate over all elements of the buffer and apply a function to each element, without removing them.
      T head()
      Return the first element of the message buffer without removing it.
      boolean isEmpty()
      Check if the message buffer is empty.
      boolean isFull()  
      boolean nonEmpty()
      Check if the message buffer is not empty.
      int size()
      How many elements are in the message buffer.
      StashBufferImpl<T> stash​(T message)
      Add one element to the end of the message buffer.
      java.lang.String toString()  
      Behavior<T> unstash​(ActorContext<T> ctx, Behavior<T> behavior, int numberOfMessages, java.util.function.Function<T,​T> wrap)
      Process numberOfMessages of the stashed messages with the behavior and the returned Behavior from each processed message.
      Behavior<T> unstash​(ActorContext<T> ctx, Behavior<T> behavior, int numberOfMessages, scala.Function1<T,​T> wrap)
      Process numberOfMessages of the stashed messages with the behavior and the returned Behavior from each processed message.
      Behavior<T> unstashAll​(ActorContext<T> ctx, Behavior<T> behavior)
      Process all stashed messages with the behavior and the returned Behavior from each processed message.
      Behavior<T> unstashAll​(ActorContext<T> ctx, Behavior<T> behavior)
      Process all stashed messages with the behavior and the returned Behavior from each processed message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • capacity

        public int capacity()
      • isEmpty

        public boolean isEmpty()
        Description copied from class: StashBuffer
        Check if the message buffer is empty.

        Specified by:
        isEmpty in interface StashBuffer<T>
        Specified by:
        isEmpty in class StashBuffer<T>
        Returns:
        if the buffer is empty
      • nonEmpty

        public boolean nonEmpty()
        Description copied from class: StashBuffer
        Check if the message buffer is not empty.

        Specified by:
        nonEmpty in interface StashBuffer<T>
        Specified by:
        nonEmpty in class StashBuffer<T>
        Returns:
        if the buffer is not empty
      • size

        public int size()
        Description copied from class: StashBuffer
        How many elements are in the message buffer.

        Specified by:
        size in interface StashBuffer<T>
        Specified by:
        size in class StashBuffer<T>
        Returns:
        the number of elements in the message buffer
      • isFull

        public boolean isFull()
        Specified by:
        isFull in interface StashBuffer<T>
        Specified by:
        isFull in class StashBuffer<T>
        Returns:
        true if no more messages can be added, i.e. size equals the capacity of the stash buffer
      • head

        public T head()
        Description copied from class: StashBuffer
        Return the first element of the message buffer without removing it.

        Specified by:
        head in interface StashBuffer<T>
        Specified by:
        head in class StashBuffer<T>
        Returns:
        the first element or throws NoSuchElementException if the buffer is empty
      • foreach

        public void foreach​(scala.Function1<T,​scala.runtime.BoxedUnit> f)
        Description copied from interface: StashBuffer
        Iterate over all elements of the buffer and apply a function to each element, without removing them.

        Specified by:
        foreach in interface StashBuffer<T>
        Parameters:
        f - the function to apply to each element
      • forEach

        public void forEach​(java.util.function.Consumer<T> f)
        Description copied from class: StashBuffer
        Iterate over all elements of the buffer and apply a function to each element, without removing them.

        Specified by:
        forEach in class StashBuffer<T>
        Parameters:
        f - the function to apply to each element
      • unstashAll

        public Behavior<T> unstashAll​(ActorContext<T> ctx,
                                      Behavior<T> behavior)
        Description copied from interface: StashBuffer
        Process all stashed messages with the behavior and the returned Behavior from each processed message. The StashBuffer will be empty after processing all messages, unless an exception is thrown or messages are stashed while unstashing.

        If an exception is thrown by processing a message a proceeding messages and the message causing the exception have been removed from the StashBuffer, but unprocessed messages remain.

        It's allowed to stash messages while unstashing. Those newly added messages will not be processed by this call and have to be unstashed in another call.

        Specified by:
        unstashAll in interface StashBuffer<T>
        Parameters:
        ctx - (undocumented)
        behavior - (undocumented)
        Returns:
        (undocumented)
      • unstashAll

        public Behavior<T> unstashAll​(ActorContext<T> ctx,
                                      Behavior<T> behavior)
        Description copied from class: StashBuffer
        Process all stashed messages with the behavior and the returned Behavior from each processed message. The StashBuffer will be empty after processing all messages, unless an exception is thrown or messages are stashed while unstashing.

        If an exception is thrown by processing a message a proceeding messages and the message causing the exception have been removed from the StashBuffer, but unprocessed messages remain.

        It's allowed to stash messages while unstashing. Those newly added messages will not be processed by this call and have to be unstashed in another call.

        Specified by:
        unstashAll in class StashBuffer<T>
        Parameters:
        ctx - (undocumented)
        behavior - (undocumented)
        Returns:
        (undocumented)
      • unstash

        public Behavior<T> unstash​(ActorContext<T> ctx,
                                   Behavior<T> behavior,
                                   int numberOfMessages,
                                   scala.Function1<T,​T> wrap)
        Description copied from interface: StashBuffer
        Process numberOfMessages of the stashed messages with the behavior and the returned Behavior from each processed message.

        The purpose of this method, compared to unstashAll is to unstash a limited number of messages and then send a message to self before continuing unstashing more. That means that other new messages may arrive in-between and those must be stashed to keep the original order of messages. To differentiate between unstashed and new incoming messages the unstashed messages can be wrapped in another message with the wrap.

        If an exception is thrown by processing a message a proceeding messages and the message causing the exception have been removed from the StashBuffer, but unprocessed messages remain.

        It's allowed to stash messages while unstashing. Those newly added messages will not be processed by this call and have to be unstashed in another call.

        Specified by:
        unstash in interface StashBuffer<T>
        Parameters:
        ctx - (undocumented)
        behavior - (undocumented)
        numberOfMessages - (undocumented)
        wrap - (undocumented)
        Returns:
        (undocumented)
      • unstash

        public Behavior<T> unstash​(ActorContext<T> ctx,
                                   Behavior<T> behavior,
                                   int numberOfMessages,
                                   java.util.function.Function<T,​T> wrap)
        Description copied from class: StashBuffer
        Process numberOfMessages of the stashed messages with the behavior and the returned Behavior from each processed message.

        The purpose of this method, compared to unstashAll, is to unstash a limited number of messages and then send a message to self before continuing unstashing more. That means that other new messages may arrive in-between and those must be stashed to keep the original order of messages. To differentiate between unstashed and new incoming messages the unstashed messages can be wrapped in another message with the wrap.

        If an exception is thrown by processing a message a proceeding messages and the message causing the exception have been removed from the StashBuffer, but unprocessed messages remain.

        It's allowed to stash messages while unstashing. Those newly added messages will not be processed by this call and have to be unstashed in another call.

        Specified by:
        unstash in class StashBuffer<T>
        Parameters:
        ctx - (undocumented)
        behavior - (undocumented)
        numberOfMessages - (undocumented)
        wrap - (undocumented)
        Returns:
        (undocumented)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object