Package gnu.mapping
Class ThreadLocation<T>
- java.lang.Object
-
- gnu.mapping.Location<T>
-
- gnu.mapping.IndirectableLocation<T>
-
- gnu.mapping.NamedLocation<T>
-
- gnu.mapping.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.
-
-
Field Summary
-
Fields inherited from class gnu.mapping.IndirectableLocation
base, DIRECT_ON_SET, INDIRECT_FLUIDS, value
-
Fields inherited from interface gnu.mapping.EnvironmentKey
FUNCTION
-
-
Constructor Summary
Constructors Constructor Description ThreadLocation()
A new anonymous fluid location.ThreadLocation(Symbol name)
ThreadLocation(Symbol name, ThreadLocal<T> thLocal)
ThreadLocation(String name)
A new anonymous fluid location but used a given name for printing.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
Get the current value of this location.T
get(T defaultValue)
String
getName()
Object
getSymbol()
boolean
isBound()
static ThreadLocation
makeAnonymous(Symbol name)
Create a fresh ThreadLocation, independent of other ThreadLocations.static ThreadLocation
makeAnonymous(String name)
Create a fresh ThreadLocation, independent of other ThreadLocations.void
set(T value)
void
setGlobal(T value)
Set the default/global value.void
setName(String name)
void
setRestore(Object oldValue)
Restore an old value.Object
setWithSave(T newValue)
Set a value, but return cookie so old value can be restored.void
undefine()
-
Methods inherited from class gnu.mapping.NamedLocation
entered, equals, getEnvironment, getKey, getKeyProperty, getKeySymbol, hashCode, matches, matches
-
Methods inherited from class gnu.mapping.IndirectableLocation
getBase, getBaseForce, isConstant, setAlias, setBase
-
Methods inherited from class gnu.mapping.Location
define, getValue, make, make, make, print, setValue, toString
-
-
-
-
Constructor Detail
-
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 Detail
-
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.
-
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 classNamedLocation<T>
-
setRestore
public void setRestore(Object oldValue)
Description copied from class:Location
Restore an old value.- Overrides:
setRestore
in classNamedLocation<T>
- Parameters:
oldValue
- the return value from a prior setWithSave.
-
undefine
public void undefine()
- Overrides:
undefine
in classIndirectableLocation<T>
-
-