const classafConcurrent::LocalRef
sys::Obj afConcurrent::LocalRef
@
Js
Manages an Obj reference stored in Actor.locals
with a unique key.
- cleanUp
Void cleanUp()
Removes this object from
Actor.locals
.- isMapped
Bool isMapped()
Returns
true
ifActor.locals
holds an entry for thisqname
.- makeWithFunc
new makeWithFunc(Str name, |->Obj?? defFunc := null)
Creates a
LocalRef
with given name.If not null,
defFunc
is called to create a default object wheneverval
is read and a value is not mapped inActor.locals
. This object is then stored and returned. This allows the creation of non-const default objects in multiple threads.initFunc
must be immutable.- name
const Str name
The variable name given to the ctor.
- qname
const Str qname
The qualified name this
ThreadLocal
is stored under inActor.locals
.qname
is calculated fromname
.- toStr
virtual override Str toStr()
Returns a string representation the referenced value.
- val
Obj? val
The object held in
Actor.locals
. If a value is not mapped when read,initFunc()
is called to create a default object.