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.
  • Field Details

    • NULL

      protected static final Object NULL
    • _val

      private volatile T _val
  • Constructor Details

    • LocklessLazyVar

      public LocklessLazyVar()
  • Method Details

    • 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 to get() 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.