Class StashBufferImpl<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  StashBufferImpl.Node<T>  
    • Constructor Summary

      Constructors 
      Constructor Description
      StashBufferImpl()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean anyMatch​(java.util.function.Predicate<T> predicate)
      Tests whether a predicate holds for at least one element of this StashBuffer.
      static <T> StashBufferImpl<T> apply​(ActorContext<T> ctx, int capacity)  
      int capacity()
      What is the capacity of this buffer.
      void clear()
      Removes all messages from the buffer.
      <U> boolean contains​(U message)
      Tests whether this StashBuffer contains a given message.
      boolean exists​(scala.Function1<T,​java.lang.Object> predicate)
      Tests whether a predicate holds for at least one element of this StashBuffer.
      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​(Procedure<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​(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​(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​(Behavior<T> behavior)
      Process all stashed messages with the behavior and the returned Behavior from each processed message.
      void unstashed​(ActorContext<T> ctx, StashBufferImpl.Node<T> node)  
      • Methods inherited from class java.lang.Object

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

      • StashBufferImpl

        public StashBufferImpl()
    • Method Detail

      • capacity

        public int capacity()
        Description copied from interface: StashBuffer
        What is the capacity of this buffer.

        Specified by:
        capacity in interface StashBuffer<T>
        Specified by:
        capacity in interface StashBuffer<T>
        Returns:
        the capacity of this buffer
      • isEmpty

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

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

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

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

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

        Specified by:
        size in interface StashBuffer<T>
        Specified by:
        size in interface 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 interface 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 interface: StashBuffer
        Return the first element of the message buffer without removing it.

        Specified by:
        head in interface StashBuffer<T>
        Specified by:
        head in interface 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​(Procedure<T> 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
      • contains

        public <U> boolean contains​(U message)
        Description copied from interface: StashBuffer
        Tests whether this StashBuffer contains a given message.

        Specified by:
        contains in interface StashBuffer<T>
        Specified by:
        contains in interface StashBuffer<T>
        Parameters:
        message - the message to test
        Returns:
        true if the buffer contains the message, false otherwise.
      • exists

        public boolean exists​(scala.Function1<T,​java.lang.Object> predicate)
        Description copied from interface: StashBuffer
        Tests whether a predicate holds for at least one element of this StashBuffer.

        Specified by:
        exists in interface StashBuffer<T>
        Parameters:
        predicate - the predicate used to test
        Returns:
        true if the predicate holds for at least one message, false otherwise.
      • anyMatch

        public boolean anyMatch​(java.util.function.Predicate<T> predicate)
        Description copied from interface: StashBuffer
        Tests whether a predicate holds for at least one element of this StashBuffer.

        Specified by:
        anyMatch in interface StashBuffer<T>
        Parameters:
        predicate - the predicate used to test
        Returns:
        true if the predicate holds for at least one message, false otherwise.
      • unstashAll

        public Behavior<T> unstashAll​(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.

        The behavior passed to unstashAll must not be unhandled.

        Specified by:
        unstashAll in interface StashBuffer<T>
        Specified by:
        unstashAll in interface StashBuffer<T>
      • unstash

        public Behavior<T> unstash​(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.

        The behavior passed to unstash must not be unhandled.

        Specified by:
        unstash in interface StashBuffer<T>
      • unstash

        public Behavior<T> unstash​(Behavior<T> behavior,
                                   int numberOfMessages,
                                   java.util.function.Function<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.

        The behavior passed to unstash must not be unhandled.

        Specified by:
        unstash in interface StashBuffer<T>
      • toString

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