Class CallStack


  • public class CallStack
    extends java.lang.Object
    An wrapper around a stack of frame objects that is aware of the message that owns it. It contains functionality to move the content of itself to another, never to copy, since a callback is unique and might be counted by implementations such as Resender.
    Author:
    Simon Thoresen Hult
    • Constructor Summary

      Constructors 
      Constructor Description
      CallStack()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear this call stack.
      ReplyHandler pop​(Routable routable)
      Pop a frame from this stack.
      void push​(ReplyHandler handler, java.lang.Object context)
      Push a handler onto the callstack of this message with a given context.
      int size()
      Returns the number of elements of the callstack.
      void swap​(CallStack other)
      Swap the content of this and the argument stack.
      • Methods inherited from class java.lang.Object

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

      • CallStack

        public CallStack()
    • Method Detail

      • push

        public void push​(ReplyHandler handler,
                         java.lang.Object context)
        Push a handler onto the callstack of this message with a given context.
        Parameters:
        handler - The reply handler to store.
        context - The context to be associated with the message for that handler.
      • pop

        public ReplyHandler pop​(Routable routable)
        Pop a frame from this stack. The handler part of the frame will be returned and the context part will be set on the given reply. Invoke this method on an empty stack and terrible things will happen.
        Parameters:
        routable - The routable that will have its context set.
        Returns:
        The next handler on the stack.
      • swap

        public void swap​(CallStack other)
        Swap the content of this and the argument stack.
        Parameters:
        other - The stack to swap content with.
      • clear

        public void clear()
        Clear this call stack. This method should only be used when you are certain that it is safe to just throw away the stack. It has similar effects to stopping a thread, you need to know where it is safe to do so.
      • size

        public int size()
        Returns the number of elements of the callstack.
        Returns:
        The number of elements.