public final class AtomicSequence extends Object
for(;;) {
long lock = sequence.get();
// any preliminary checking (capacity, etc. can be done here
// the next call ensures that no other thread has modified the sequence
// while we work
if(sequence.update(lock)) {
try {
// update something atomically here
return;
} finally {
sequence.commit();
}
}
}
Created by jcairns on 9/24/14.| Constructor and Description |
|---|
AtomicSequence() |
| Modifier and Type | Method and Description |
|---|---|
void |
commit()
commit the change to the sequence
|
long |
get() |
long |
getAtomic()
force a fenced read of the sequence, only required if the sequence is known out of date
|
boolean |
update(long sequence) |
public long get()
public long getAtomic()
public boolean update(long sequence)
sequence - - input sequence numberpublic void commit()
Copyright © 2012–2017 Conversant Engineering. All rights reserved.