Interface RecyclerFactory
public interface RecyclerFactory
Contract for
Recycler
factories.- Since:
- 3.0.0
-
Method Details
-
create
Creates a new recycler using the given supplier function for initial instances.- Type Parameters:
V
- the recyclable type- Parameters:
supplier
- a function to provide initial instances- Returns:
- a new recycler
-
create
Creates a new recycler using the given supplier and cleaner functions.The provided supplier needs to make sure that generated instances are always clean.
Recycled instances are always guaranteed to be clean. The cleaning of an instance can take place either just before acquisition or prior to admitting it back into the reusable instances pool. The moment when the cleaning will be carried out is implementation dependent. Though a released instance should ideally be cleaned immediately to avoid keeping references to unused objects.
- Type Parameters:
V
- the recyclable type- Parameters:
supplier
- a function to provide initial (and clean!) instancescleaner
- function to reset an instance before reuse- Returns:
- a new recycler
-