Package org.aksw.commons.util.ref
Class LazyRef<T>
- java.lang.Object
-
- org.aksw.commons.util.ref.LazyRef<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
Serializable,java.util.function.Supplier<Ref<T>>
public class LazyRef<T> extends Object implements java.util.function.Supplier<Ref<T>>, Serializable
A supplier for a ref backed by a root ref. Calling .get() creates the root ref lazily if it does not yet exist. Once the user ref is released, the release of the root ref is only scheduled. Another request to .get() cancels a pending release.- Author:
- raven
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Ref<T>backendRefprotected java.util.function.Supplier<? extends Ref<T>>backendRefSupplierprotected longcloseDelayInMsprotected Stringlabelprotected Ref<T>rootRefprotected Timertimer
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactualClose()static <T> LazyRef<T>create(String label, java.util.function.Supplier<? extends Ref<T>> rootRefFactory, long delayInMs)Ref<T>get()
-