Interface IUsageTracker<E>

  • All Known Implementing Classes:
    ConcurrentIdentityUsageTracker

    public interface IUsageTracker<E>
    Class tracking usages of objects.

    An object must first be registered to the tracker. Afterwards, users can call acquire(Object) to notify their use of the item, and release(Object) to notify they stop using it.
    When an object is not used anymore, it shall be removed using deregister(Object).

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void acquire​(E item)
      Notifies this tracker that the item starts being used somewhere.
      long count​(E item)
      Returns the number of times this item is being used.
      void deregister​(E item)
      Deregisters an item from this tracker.
      Collection<E> getTrackedItems()
      Gets the list of all items tracked by this instance.
      boolean isTracking​(Object item)
      Tests whether the provided item is tracked by this component.
      void register​(E item)
      Registers an item in this tracker.
      long release​(E item)
      Notifies this tracker that the item stopped being used.
    • Method Detail

      • register

        void register​(E item)
        Registers an item in this tracker.
      • deregister

        void deregister​(E item)
        Deregisters an item from this tracker.
        Throws:
        IllegalStateException - if the item is still being used, i.e. its counts is positive.
      • count

        @Nonnegative
        long count​(E item)
        Returns the number of times this item is being used.
      • acquire

        void acquire​(E item)
        Notifies this tracker that the item starts being used somewhere.
      • release

        long release​(E item)
        Notifies this tracker that the item stopped being used.
        Returns:
        the number of times the item is used after this release.
      • getTrackedItems

        Collection<E> getTrackedItems()
        Gets the list of all items tracked by this instance.
      • isTracking

        boolean isTracking​(Object item)
        Tests whether the provided item is tracked by this component.