Class CallStack

java.lang.Object
com.yahoo.messagebus.CallStack

public class CallStack extends 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 Details

    • CallStack

      public CallStack()
  • Method Details

    • push

      public void push(ReplyHandler handler, 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.