org.apache.commons.transaction.util
Class RendezvousBarrier

java.lang.Object
  extended by org.apache.commons.transaction.util.RendezvousBarrier

public class RendezvousBarrier
extends Object

Simple barrier that blocks until all parties have either called or have arrived at the meeting point. Very useful for testing or other purposes that require to make concurrent settings deterministic.

Version:
$Id: RendezvousBarrier.java 493628 2007-01-07 01:42:48Z joerg $

Field Summary
protected  int count
           
static int DEFAULT_TIMEOUT
           
protected  LoggerFacade logger
           
protected  String name
           
protected  int parties
           
protected  long timeout
           
 
Constructor Summary
RendezvousBarrier(String name, int parties, long timeout, LoggerFacade logger)
           
RendezvousBarrier(String name, LoggerFacade logger)
           
RendezvousBarrier(String name, long timeout, LoggerFacade logger)
           
 
Method Summary
 void call()
          Notify the barrier that you (the current thread) will not come to the meeting point.
 void meet()
          Meet at this barrier.
 void reset()
          Releases all waiting threads and resets the number of parties already arrived.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

parties

protected final int parties

name

protected final String name

count

protected int count

timeout

protected long timeout

logger

protected LoggerFacade logger
Constructor Detail

RendezvousBarrier

public RendezvousBarrier(String name,
                         LoggerFacade logger)

RendezvousBarrier

public RendezvousBarrier(String name,
                         long timeout,
                         LoggerFacade logger)

RendezvousBarrier

public RendezvousBarrier(String name,
                         int parties,
                         long timeout,
                         LoggerFacade logger)
Method Detail

call

public void call()
Notify the barrier that you (the current thread) will not come to the meeting point. Same thing as meet(), but does not not let you wait.


meet

public void meet()
          throws InterruptedException
Meet at this barrier. The current thread will either block when there are missing parties for this barrier or it is the last one to complete this meeting and the barrier will release its block. In this case all other waiting threads will be notified.

Throws:
InterruptedException - if the current thread is interrupted while waiting

reset

public void reset()
Releases all waiting threads and resets the number of parties already arrived.



Copyright © 2004-2009 Apache Software Foundation. All Rights Reserved.