Class QueueTemplate.Queue

  • Enclosing class:
    QueueTemplate

    public static class QueueTemplate.Queue
    extends java.lang.Object
    Create an object queue. "Getters" wait 'till something appears in the queue.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int max  
    • Constructor Summary

      Constructors 
      Constructor Description
      Queue()
      Create a new Q of a maximum possible size
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear the queue.
      long count()
      Return the total number of items Q'd.
      java.lang.Object get​(int timeout)
      Return the next item on the queue, waiting for up to "timeout" seconds or for an interrupt.
      long getCreated()
      Return creation time (ms since epoch).
      long getExpires()
      Get the expiration period of the Queue (in ms).
      boolean isClosed()
      Get the closed state.
      void kick()
      Send a notify: for debugging
      long lastIn()
      Return the last time a Q insertion was attempted.
      long lastOut()
      Return the last time a Q removal was attempted.
      boolean put​(java.lang.Object item)
      Put an item on the queue if it's open and not full.
      boolean put​(java.lang.Object item, boolean force)
      Put an item on the queue if it's not full.
      boolean setClosed​(boolean closed)
      Set the closed state.
      void setExpires​(long expires)
      Set the expiration period of the Queue (in ms).
      int size()
      How many items are queue'd.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • max

        public static int max
    • Constructor Detail

      • Queue

        public Queue()
        Create a new Q of a maximum possible size
    • Method Detail

      • get

        public java.lang.Object get​(int timeout)
        Return the next item on the queue, waiting for up to "timeout" seconds or for an interrupt.
        Returns:
        the top of the Q, or null.
      • put

        public boolean put​(java.lang.Object item)
        Put an item on the queue if it's open and not full.
      • put

        public boolean put​(java.lang.Object item,
                           boolean force)
        Put an item on the queue if it's not full. If "force" is true, override the "closed" flag.
      • size

        public int size()
        How many items are queue'd.
      • kick

        public void kick()
        Send a notify: for debugging
      • lastIn

        public long lastIn()
        Return the last time a Q insertion was attempted.
        Returns:
        -1 if no attempts were made.
      • lastOut

        public long lastOut()
        Return the last time a Q removal was attempted.
        Returns:
        -1 if no attempts were made.
      • count

        public long count()
        Return the total number of items Q'd.
        Returns:
        The # of Q'd items.
      • getExpires

        public long getExpires()
        Get the expiration period of the Queue (in ms). The notion of when a queue expires is application dependent. Applications can look at count() lastIn(), lastOut(). and created() to determine when the Q is expired for them.
      • setExpires

        public void setExpires​(long expires)
        Set the expiration period of the Queue (in ms).
      • getCreated

        public long getCreated()
        Return creation time (ms since epoch).
      • clear

        public void clear()
        Clear the queue.
      • setClosed

        public boolean setClosed​(boolean closed)
        Set the closed state.
      • isClosed

        public boolean isClosed()
        Get the closed state.
      • toString

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