public class LazyStickyPool<A>
A class LazyStickyPool
is a lazy pool of resources where a borrow may "stick" the borrowed instance to an object.
Any subsequent borrows using the same object will return the same pooled instance.
class LazyStickyPool
Constructor and Description |
---|
LazyStickyPool(int size,
kotlin.jvm.functions.Function0<? extends A> newInstance)
A
class LazyStickyPool is a lazy pool of resources where a borrow may "stick" the borrowed instance to an object.
Any subsequent borrows using the same object will return the same pooled instance. |
Modifier and Type | Method and Description |
---|---|
A |
borrow(java.lang.Object stickTo) |
kotlin.Pair<java.lang.Object,A> |
borrow() |
java.lang.Iterable<A> |
close() |
void |
release(java.lang.Object stickTo,
A instance) |
<R> R |
run(java.lang.Object stickToOrNull,
kotlin.jvm.functions.Function1<? super A,? extends R> withInstance) |
public LazyStickyPool(int size, kotlin.jvm.functions.Function0<? extends A> newInstance)
A class LazyStickyPool
is a lazy pool of resources where a borrow may "stick" the borrowed instance to an object.
Any subsequent borrows using the same object will return the same pooled instance.
size
- The size of the pool.newInstance
- The function to call to create a pooled resource.class LazyStickyPool
public A borrow(java.lang.Object stickTo)
public kotlin.Pair<java.lang.Object,A> borrow()
public void release(java.lang.Object stickTo, A instance)
public <R> R run(java.lang.Object stickToOrNull, kotlin.jvm.functions.Function1<? super A,? extends R> withInstance)
public java.lang.Iterable<A> close()