public final class CountDownCommitBarrier extends CommitBarrier
CountDownLatch
. 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.Txn)
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
lock, statusCondition
Constructor and Description |
---|
CountDownCommitBarrier(int parties)
Create a new CountDownCommitBarrier that uses an unfair lock.
|
CountDownCommitBarrier(int parties,
boolean fair)
Creates a new CountDownCommitBarrier.
|
Modifier and Type | Method and Description |
---|---|
void |
atomicIncParties()
Adds 1 additional party to this CountDownCommitBarrier.
|
void |
atomicIncParties(int extra)
Atomically adds additional parties to this CountDownCommitBarrier.
|
void |
countDown()
Signal that one party has returned.
|
int |
getParties()
Returns the number of parties that want to join this CountDownCommitBarrier.
|
void |
incParties(Txn tx,
int extra)
Increases the number of parties that need to return before this CommitBarrier can open.
|
protected boolean |
isLastParty() |
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
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.public int getParties()
protected boolean isLastParty()
isLastParty
in class CommitBarrier
public void countDown()
CountDownLatch.countDown()
method provides.public void atomicIncParties()
CommitBarrierOpenException
- if this CountDownCommitBarrier already is committed or aborted.atomicIncParties(int)
public void atomicIncParties(int extra)
incParties(org.multiverse.api.Txn, int)
.extra
- the additional parties.IllegalArgumentException
- if extra smaller than 0.CommitBarrierOpenException
- if this CountDownCommitBarrier already is open.public void incParties(Txn tx, int extra)
tx
- the transaction where this operation lifts on.extra
- the number of extra partiesNullPointerException
- if tx is null.IllegalArgumentException
- is extra smaller than zero.IllegalTxnStateException
- if the transaction is not in the correct
state for this operation (so not active).Copyright © 2020. All rights reserved.