Package com.activeviam.util
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, andrelease(Object)to notify they stop using it.
When an object is not used anymore, it shall be removed usingderegister(Object).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidacquire(E item)Notifies this tracker that the item starts being used somewhere.longcount(E item)Returns the number of times this item is being used.voidderegister(E item)Deregisters an item from this tracker.Collection<E>getTrackedItems()Gets the list of all items tracked by this instance.booleanisTracking(Object item)Tests whether the provided item is tracked by this component.voidregister(E item)Registers an item in this tracker.longrelease(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.
-
-