|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.multiverse.commitbarriers.CommitBarrier
org.multiverse.commitbarriers.CountDownCommitBarrier
public final class CountDownCommitBarrier
A synchronization aid that allows a set of threads and transaction to all wait for each other to reach a common barrier point; once this barrier is opened, all transaction atomically commit. A CountDownCommitBarrier is useful in programs involving a fixed sized party of threads/transactions that must occasionally wait for each other.
The CountDownCommitBarrier looks a lot like theCountDownLatch. So if you have
experience with that functionality, this one should feel familiar.
A CountDownCommitBarrier is initialized with a given count. The
CommitBarrier.joinCommit(org.multiverse.api.Transaction) await} methods block until the current count reaches
zero due to invocations of the countDown() method, after which all waiting threads are released. Unlike the
CountDownLatch, it isn't allowed for a new transaction to call one of the join methods after the barrier has
aborted or committed.
This functionality is useful for two phase commit related functionality.
The CountDownCommitBarrier can't be reused, so it is not cyclic like the CyclicBarrier.
A CountDownCommitBarrier is thread-safe to use of course.
VetoCommitBarrier| Field Summary |
|---|
| Fields inherited from class org.multiverse.commitbarriers.CommitBarrier |
|---|
lock, statusCondition |
| Constructor Summary | |
|---|---|
CountDownCommitBarrier(int parties)
Create a new CountDownCommitBarrier that uses an unfair lock. |
|
CountDownCommitBarrier(int parties,
boolean fair)
Creates a new CountDownCommitBarrier. |
|
| Method Summary | |
|---|---|
void |
countDown()
Signal that one party has returned. |
int |
getParties()
Returns the number of parties that want to join this CountDownCommitBarrier. |
void |
incParties()
Adds 1 additional party to this CountDownCommitBarrier. |
void |
incParties(int extra)
Adds additional parties to this CountDownCommitBarrier. |
void |
incParties(Transaction tx,
int extra)
Increases the number of parties that need to return before this CommitBarrier can open. |
protected boolean |
isLastParty()
|
| Methods inherited from class org.multiverse.commitbarriers.CommitBarrier |
|---|
abort, addJoiner, awaitOpen, awaitOpenUninterruptibly, ensureNotDead, executeTasks, finish, getNumberWaiting, getStatus, isAborted, isClosed, isCommitted, joinCommit, joinCommitUninterruptibly, registerOnAbortTask, registerOnCommitTask, setScheduledExecutorService, setTimeout, signalAborted, signalCommit, tryAwaitOpen, tryAwaitOpenUninterruptibly, tryJoinCommit, tryJoinCommit, tryJoinCommitUninterruptibly |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CountDownCommitBarrier(int parties)
parties - the number of parties waiting. If the number of parties is 0, the VetoCommitBarrier is created
committed, else it will be closed.
IllegalArgumentException - if parties is smaller than 0.
public CountDownCommitBarrier(int parties,
boolean fair)
parties - the number of parties waiting. If the number of parties is 0, the VetoCommitBarrier is created
committed, else it will be closed.fair - if the lock bu this CountDownCommitBarrier is fair.
IllegalArgumentException - if parties smaller than 0.| Method Detail |
|---|
public int getParties()
protected boolean isLastParty()
isLastParty in class CommitBarrierpublic void countDown()
CountDownLatch.countDown() method provides.
public void incParties()
CommitBarrierOpenException - if this CountDownCommitBarrier already is committed or aborted.incParties(int)public void incParties(int extra)
incParties(org.multiverse.api.Transaction, int).
extra - the additional parties.
IllegalArgumentException - if extra smaller than 0.
CommitBarrierOpenException - if this CountDownCommitBarrier already is open.
public void incParties(Transaction tx,
int extra)
tx - the transaction where this operation lifts on.extra - the number of extra parties
NullPointerException - if tx is null.
IllegalArgumentException - is extra smaller than zero.
DeadTransactionException - if the transaction is dead
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||