Package gw.util.concurrent
Class LocklessLazyVar<T>
java.lang.Object
gw.util.concurrent.LocklessLazyVar<T>
- Direct Known Subclasses:
LazyType
,LazyTypeResolver
Implements the lazy initialization pattern.
No locking of any kind is used.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A simple init interface to make LockingLazyVar's easier to construct from gosu. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal T
clear()
Clears the variable, forcing the next call toget()
to re-calculate the value.final 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 Details
-
NULL
-
_val
-
-
Constructor Details
-
LocklessLazyVar
public LocklessLazyVar()
-
-
Method Details
-
get
- Returns:
- the value of this lazy var, created if necessary
-
init
-
clear
Clears the variable, forcing the next call toget()
to re-calculate the value. -
initDirectly
-
isLoaded
public boolean isLoaded() -
make
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.
-