|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ProgrammaticLong
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
ProgrammaticLong also is able to participate in full blown transactions.
A big reason why this ProgrammaticLong 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 | |
|---|---|
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 ProgrammaticLong. |
long |
atomicSet(long newValue)
Sets the new value and completely ignores the Transaction stored in the ThreadLocalTransaction. |
void |
commutingInc(long amount)
Increments the value stored in this ProgrammaticReference. |
void |
commutingInc(Transaction tx,
long amount)
Increments the value stored in this ProgrammaticLong. |
long |
get()
Gets the current value stores in this ProgrammaticLong. |
long |
get(Transaction tx)
Gets the current value stores in this ProgrammaticLong. |
void |
inc(long amount)
Increments the counter with the specified amount. |
void |
inc(Transaction tx,
long amount)
Increments the value stored in this ProgrammaticLong 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
IllegalThreadStateException - if the transaction is not active.long get(Transaction tx)
tx - the transaction to use.
IllegalThreadStateException - if the transaction is not active.
NullPointerException - if tx is null.
ReadConflictlong atomicGet()
long set(long newValue)
newValue - the new value to store in this ProgrammaticLong.
long set(Transaction tx,
long newValue)
tx - the Transaction to use.newValue - the new value
IllegalThreadStateException
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 ProgrammaticLong with.
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
NullPointerException - if tx is null.
IllegalThreadStateException - if not in the correct state for this operation.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||