Package gnu.mapping

Class ThreadLocation<T>

All Implemented Interfaces:
EnvironmentKey, Named, Map.Entry<EnvironmentKey,T>

public class ThreadLocation<T> extends NamedLocation<T> implements Named
A Location that forwards to a thread-specific Location.
  • Constructor Details

    • ThreadLocation

      public ThreadLocation()
      A new anonymous fluid location.
    • ThreadLocation

      public ThreadLocation(String name)
      A new anonymous fluid location but used a given name for printing. However, the binding is not bound to the name as a visible binding.
    • ThreadLocation

      public ThreadLocation(Symbol name)
    • ThreadLocation

      public ThreadLocation(Symbol name, ThreadLocal<T> thLocal)
  • Method Details

    • makeAnonymous

      public static ThreadLocation makeAnonymous(String name)
      Create a fresh ThreadLocation, independent of other ThreadLocations.
      Parameters:
      name - used for printing, but not identification.
    • makeAnonymous

      public static ThreadLocation makeAnonymous(Symbol name)
      Create a fresh ThreadLocation, independent of other ThreadLocations.
      Parameters:
      name - used for printing, but not identification.
    • setGlobal

      public void setGlobal(T value)
      Set the default/global value.
    • get

      public T get()
      Description copied from class: Location
      Get the current value of this location.
      Specified by:
      get in class Location<T>
    • get

      public T get(T defaultValue)
      Overrides:
      get in class Location<T>
    • isBound

      public boolean isBound()
      Specified by:
      isBound in class Location<T>
    • set

      public void set(T value)
      Specified by:
      set in class Location<T>
    • setWithSave

      public Object setWithSave(T newValue)
      Description copied from class: Location
      Set a value, but return cookie so old value can be restored. This is intended for fluid-let where (in the case of multiple threads) a simple save-restore isn't always the right thing.
      Overrides:
      setWithSave in class NamedLocation<T>
    • setRestore

      public void setRestore(Object oldValue)
      Description copied from class: Location
      Restore an old value.
      Overrides:
      setRestore in class NamedLocation<T>
      Parameters:
      oldValue - the return value from a prior setWithSave.
    • undefine

      public void undefine()
      Overrides:
      undefine in class IndirectableLocation<T>
    • getName

      public String getName()
      Specified by:
      getName in interface Named
    • getSymbol

      public Object getSymbol()
      Specified by:
      getSymbol in interface Named
    • setName

      public void setName(String name)
      Specified by:
      setName in interface Named