TxnLocal should get some of the methods from Ref:
- the access shortcuts
apply() and update(v)
- read+write forms
swap, transform, transformIfDefined, +=, -=, and *=
I think compareAndSet (and other Ref methods whose success or failure is determined by concurrent accesses) would be misleading, because TxnLocal instances are isolated.
Also, overriding initialValue should perhaps be replaced with a by-name parameter to a factory method. This is more Scala-ish, but makes it more difficult to get access to the current Txn context.
TxnLocalshould get some of the methods fromRef:apply()andupdate(v)swap,transform,transformIfDefined,+=,-=, and*=I think
compareAndSet(and otherRefmethods whose success or failure is determined by concurrent accesses) would be misleading, becauseTxnLocalinstances are isolated.Also, overriding
initialValueshould perhaps be replaced with a by-name parameter to a factory method. This is more Scala-ish, but makes it more difficult to get access to the currentTxncontext.