Package com.io7m.jpuddle.core
Interface JPPoolableListenerType<K,T,C>
- Type Parameters:
K- The type of keys used to fetch objectsT- The type of objects within poolsC- The type of contextual values used to create objects
public interface JPPoolableListenerType<K,T,C>
The type of listeners used to manipulate objects within pools.
-
Method Summary
Modifier and TypeMethodDescriptionCalled when an object is to be created.voidCalled when an object is to be deleted.voidCalled on errors.longonEstimateSize(C c, K key) Estimate the size of the object that will be created forkey.longCalled when the size ofvalueis required.voidCalled when an existing object is to be reused.
-
Method Details
-
onEstimateSize
Estimate the size of the object that will be created forkey. If the object size cannot be estimated, the function should return0. The purpose of estimation is to avoid having to allocate an object and then finding out afterwards that the object is too large for the cache. If the sizes are known ahead of time, allocations can be avoided.- Parameters:
c- A context valuekey- A key- Returns:
- The estimated size of the object
-
onCreate
Called when an object is to be created.- Parameters:
c- A context valuekey- A key- Returns:
- A new object
-
onGetSize
Called when the size ofvalueis required.- Parameters:
c- A context valuekey- A keyvalue- The object to be measured- Returns:
- The size of
value
-
onReuse
Called when an existing object is to be reused.- Parameters:
c- A context valuekey- A keyvalue- The object to be reused
-
onDelete
Called when an object is to be deleted. The method should delete any resourced associated withvalue.- Parameters:
c- A context valuekey- A keyvalue- The object to be deleted
-
onError
Called on errors.- Parameters:
c- A context valuekey- A keyvalue- The value associated with the error, if anye- The exception raised
-