| java.lang.Object org.apache.commons.transaction.util.TurnBarrier
TurnBarrier | public class TurnBarrier (Code) | | Simple turn based barrier to make a sequence of calls from different threads deterministic.
This is very useful for testing where you want to have a continuous flow throughout
different threads. The idea is to have an ordered sequence of steps where step n can not be
executed before n-1.
version: $Id: TurnBarrier.java 493628 2007-01-07 01:42:48Z joerg $ |
Method Summary | |
public synchronized void | reset() Starts the barrier over again. | public synchronized void | signalTurn(int turnNumber) Signals the next turn. | public synchronized void | waitForTurn(int turnNumber) Blockingly waits for the given turn. |
DEFAULT_TIMEOUT | final public static long DEFAULT_TIMEOUT(Code) | | |
currentNumber | protected int currentNumber(Code) | | |
startNumber | final protected int startNumber(Code) | | |
timeout | final protected long timeout(Code) | | |
TurnBarrier | public TurnBarrier(String name, LoggerFacade logger)(Code) | | Creates a new turn barrier starting with turn 0 with an unlimited timeout.
Parameters: name - the name of the barrier Parameters: logger - logger for debug output |
TurnBarrier | public TurnBarrier(String name, long timeout, LoggerFacade logger)(Code) | | Creates a new turn barrier starting with turn 0.
Parameters: name - the name of the barrier Parameters: timeout - timeout for threads to wait for their turn Parameters: logger - logger for debug output |
TurnBarrier | public TurnBarrier(String name, long timeout, LoggerFacade logger, int startTurn)(Code) | | Creates a new turn barrier.
Parameters: name - the name of the barrier Parameters: timeout - timeout for threads to wait for their turn Parameters: logger - logger for debug output Parameters: startTurn - the turn to start with |
reset | public synchronized void reset()(Code) | | Starts the barrier over again. The next turn will be the one the barrier was started with.
|
signalTurn | public synchronized void signalTurn(int turnNumber)(Code) | | Signals the next turn. Any thread waiting for the turn will be allowed to continue.
Parameters: turnNumber - the next turn number |
|
|