Package gw.util.concurrent
Class LocklessLazyVar<T>
- java.lang.Object
-
- gw.util.concurrent.LocklessLazyVar<T>
-
- Direct Known Subclasses:
LazyType
,LazyTypeResolver
public abstract class LocklessLazyVar<T> extends Object
Implements the lazy initialization pattern. No locking of any kind is used.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LocklessLazyVar.LazyVarInit<Q>
A simple init interface to make LockingLazyVar's easier to construct from gosu.
-
Constructor Summary
Constructors Constructor Description LocklessLazyVar()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
clear()
Clears the variable, forcing the next call toget()
to re-calculate the value.T
get()
protected abstract T
init()
protected void
initDirectly(T val)
boolean
isLoaded()
static <Q> LocklessLazyVar<Q>
make(LocklessLazyVar.LazyVarInit<Q> closure)
Creates a new LockingLazyVar based on the type of the LazyVarInit passed in.
-
-
-
Field Detail
-
NULL
protected static final Object NULL
-
-
Method Detail
-
get
public final T get()
- Returns:
- the value of this lazy var, created if necessary
-
init
protected abstract T init()
-
clear
public final T clear()
Clears the variable, forcing the next call toget()
to re-calculate the value.
-
initDirectly
protected void initDirectly(T val)
-
isLoaded
public boolean isLoaded()
-
make
public static <Q> LocklessLazyVar<Q> make(LocklessLazyVar.LazyVarInit<Q> closure)
Creates a new LockingLazyVar based on the type of the LazyVarInit passed in. This method is intended to be called with a lambda or block from Gosu.
-
-