Class ClientTracker.OperationQueue

  • Enclosing class:
    ClientTracker

    private static class ClientTracker.OperationQueue
    extends java.lang.Object
    Data structure for holding ClientOperation objects which (may) need to be applied in the future. Operations are dumped here if they cannot be performed immediately because the client in question is not (yet) known by this tracker. The hope is that the client will register at some point in the future and the pending operations can be applied then. However, this may never happen, so the queue maintains its own expiry system to throw out old events.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Collection opList_  
      private java.util.Timer tidyTimer_  
    • Constructor Summary

      Constructors 
      Constructor Description
      OperationQueue()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(ClientTracker.ClientOperation op)
      Add a new client operation which may get the opportunity to be performed some time in the future.
      void apply​(ClientTracker.TrackedClient client)
      Apply any pending operations to given client.
      void clear()
      Removes all entries from this queue.
      void discard​(ClientTracker.TrackedClient client)
      Discards any operations corresponding to a given client, presumably because the client is about to disappear.
      void discardOld​(long maxAge)
      Throws away any pending operations which are older than a certain age, presumably in the expectation that their client will never register.
      ClientTracker.ClientOperation[] getOperations()
      Returns an array containing all the operations currently pending.
      • Methods inherited from class java.lang.Object

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

      • opList_

        private final java.util.Collection opList_
      • tidyTimer_

        private java.util.Timer tidyTimer_
    • Constructor Detail

      • OperationQueue

        OperationQueue()
        Constructor.
    • Method Detail

      • add

        public void add​(ClientTracker.ClientOperation op)
        Add a new client operation which may get the opportunity to be performed some time in the future.
        Parameters:
        op - oeration to add
      • apply

        public void apply​(ClientTracker.TrackedClient client)
        Apply any pending operations to given client. This client was presumably unavailable at the time such operations were queued.
        Parameters:
        client - client to apply pending operations to
      • discard

        public void discard​(ClientTracker.TrackedClient client)
        Discards any operations corresponding to a given client, presumably because the client is about to disappear.
        Parameters:
        client - client to forget about
      • discardOld

        public void discardOld​(long maxAge)
        Throws away any pending operations which are older than a certain age, presumably in the expectation that their client will never register.
        Parameters:
        maxAge - oldest operations (in milliseconds) permitted to remain in the queue
      • clear

        public void clear()
        Removes all entries from this queue.
      • getOperations

        public ClientTracker.ClientOperation[] getOperations()
        Returns an array containing all the operations currently pending.
        Returns:
        operation list