|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ProgrammaticLongRef
A transactional long that can be used to integrate Multiverse in environments where instrumentation is not desired or to provide access to features not yet integrated in the instrumentation (for example the commutingInc support).
It can be compared to theAtomicLong except that this
ProgrammaticLongRef also is able to participate in full blown transactions.
A big reason why this ProgrammaticLongRef is added, is that it can be used as a size field in
Transactional collections. Normally collections conflict on the size field even if other parts of
the operations can be executed in parallel. Using the commutingInc methods it is possible to
createReference commuting operations that prevent the unwanted conflict.
In Multiverse 0.6 commuting operations will be made available on a general level, but for the
time being this gives the biggest bang for the buck.
| Method Summary | |
|---|---|
void |
atomicChangeMod()
|
boolean |
atomicCompareAndSet(long expected,
long update)
Executes a compare and set operation atomically, so it doesn't look at a running transaction stored in the ThreadLocalTransaction. |
long |
atomicGet()
Gets the last committed value atomically without looking at a Transaction stored in the ThreadLocalTransaction. |
void |
atomicInc(long amount)
Atomically increments the value stores in this ProgrammaticLongRef. |
long |
atomicSet(long newValue)
Sets the new value and completely ignores the Transaction stored in the ThreadLocalTransaction. |
void |
changeMod()
|
void |
changeMod(Transaction tx)
|
void |
commutingInc(long amount)
Increments the value stored in this ProgrammaticRef. |
void |
commutingInc(Transaction tx,
long amount)
Increments the value stored in this ProgrammaticLongRef. |
long |
get()
Gets the current value stores in this ProgrammaticLongRef. |
long |
get(Transaction tx)
Gets the current value stores in this ProgrammaticLongRef. |
void |
inc(long amount)
Increments the counter with the specified amount. |
void |
inc(Transaction tx,
long amount)
Increments the value stored in this ProgrammaticLongRef using the provided transaction. |
long |
set(long newValue)
Sets the new value. |
long |
set(Transaction tx,
long newValue)
This call doesn't look at the ThreadLocalTransaction, so you have complete control on the transaction used. |
| Method Detail |
|---|
long get()
ReadConflict
java.lang.IllegalThreadStateException - if the transaction is not active.long get(Transaction tx)
tx - the transaction to use.
java.lang.IllegalThreadStateException - if the transaction is not active.
java.lang.NullPointerException - if tx is null.
ReadConflictlong atomicGet()
long set(long newValue)
newValue - the new value to store in this ProgrammaticLongRef.
long set(Transaction tx,
long newValue)
tx - the Transaction to use.newValue - the new value
java.lang.IllegalThreadStateException
java.lang.NullPointerException - if tx is null
ControlFlowErrorlong atomicSet(long newValue)
newValue - the new value
todo: exceptions
boolean atomicCompareAndSet(long expected,
long update)
AtomicLong.compareAndSet(long, long).
expected - the expected value.update - the new value
void inc(long amount)
amount - the amount to increase the value with.
void inc(Transaction tx,
long amount)
tx - the Transaction to use.amount - the amount the increase this ProgrammaticLongRef with.
java.lang.NullPointerException - if tx is null.void atomicInc(long amount)
amount - the amount to increase the value with.void commutingInc(long amount)
amount - the amount to increase with.
void commutingInc(Transaction tx,
long amount)
tx - the transaction to use.amount - the amount to increase the value with
java.lang.NullPointerException - if tx is null.
java.lang.IllegalThreadStateException - if not in the correct state for this operation.void changeMod()
void changeMod(Transaction tx)
void atomicChangeMod()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||