Class LockingLazyVar<T>


  • public abstract class LockingLazyVar<T>
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  LockingLazyVar.LazyVarInit<Q>
      A simple init interface to make LockingLazyVar's easier to construct from gosu.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.locks.Lock _lock  
      private T _val  
      protected static java.lang.Object NULL  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        LockingLazyVar()
      Constructs a LockingLazyVar that will use itself as the object of synchronization.
      protected LockingLazyVar​(java.util.concurrent.locks.Lock lock)
      Constructs a LockingLazyVar that will synchronize on the given object.
    • Field Detail

      • NULL

        protected static final java.lang.Object NULL
      • _val

        private volatile T _val
      • _lock

        private final java.util.concurrent.locks.Lock _lock
    • Constructor Detail

      • LockingLazyVar

        public LockingLazyVar()
        Constructs a LockingLazyVar that will use itself as the object of synchronization.
      • LockingLazyVar

        protected LockingLazyVar​(java.util.concurrent.locks.Lock lock)
        Constructs a LockingLazyVar that will synchronize on the given object.
    • 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 to get() to re-calculate the value.
      • clearNoLock

        public final void clearNoLock()
      • initDirectly

        protected void initDirectly​(T val)
      • isLoaded

        public boolean isLoaded()
      • make

        public static <Q> LockingLazyVar<Q> make​(LockingLazyVar.LazyVarInit<Q> init)
        Creates a new LockingLazyVar based on the type of the LazyVarInit passed in. This method is intended to be called with blocks from Gosu.