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, 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
Modifier and TypeMethodDescriptionvoidNotifies this tracker that the item starts being used somewhere.longReturns the number of times this item is being used.voidderegister(E item) Deregisters an item from this tracker.Gets the list of all items tracked by this instance.booleanisTracking(Object item) Tests whether the provided item is tracked by this component.voidRegisters an item in this tracker.longNotifies this tracker that the item stopped being used.
-
Method Details
-
register
Registers an item in this tracker. -
deregister
Deregisters an item from this tracker.- Throws:
IllegalStateException- if the item is still being used, i.e. its counts is positive.
-
count
Returns the number of times this item is being used. -
acquire
Notifies this tracker that the item starts being used somewhere. -
release
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
Tests whether the provided item is tracked by this component.
-