org.jgroups.util
Class CondVar

java.lang.Object
  extended by org.jgroups.util.CondVar

public class CondVar
extends java.lang.Object

Class that checks on a condition and - if condition doesn't match the expected result - waits until the result matches the expected result, or a timeout occurs. First version used WaitableBoolean from util.concurrent, but that class would not allow for timeouts.

Version:
$Id: CondVar.java,v 1.3 2004/12/31 14:10:40 belaban Exp $
Author:
Bela Ban

Constructor Summary
CondVar(java.lang.String name, java.lang.Object cond)
           
CondVar(java.lang.String name, java.lang.Object cond, java.lang.Object lock)
           
 
Method Summary
 java.lang.Object get()
           
 java.lang.Object getLock()
           
 void set(java.lang.Object result)
          Sets the result
 java.lang.String toString()
           
 void waitUntil(java.lang.Object result)
           
 void waitUntil(java.lang.Object result, long timeout)
          Waits until the condition matches the expected result.
 void waitUntilWithTimeout(java.lang.Object result, long timeout)
          Waits until the condition matches the expected result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CondVar

public CondVar(java.lang.String name,
               java.lang.Object cond)

CondVar

public CondVar(java.lang.String name,
               java.lang.Object cond,
               java.lang.Object lock)
Method Detail

get

public java.lang.Object get()

set

public void set(java.lang.Object result)
Sets the result


getLock

public java.lang.Object getLock()

waitUntilWithTimeout

public void waitUntilWithTimeout(java.lang.Object result,
                                 long timeout)
                          throws TimeoutException
Waits until the condition matches the expected result. Returns immediately if they match, otherwise waits for timeout milliseconds or until the results match.

Parameters:
result - The result, needs to match the condition (using equals()).
timeout - Number of milliseconds to wait. A value of <= 0 means to wait forever
Throws:
TimeoutException - Thrown if the result still doesn't match the condition after timeout milliseconds have elapsed

waitUntil

public void waitUntil(java.lang.Object result,
                      long timeout)
Waits until the condition matches the expected result. Returns immediately if they match, otherwise waits for timeout milliseconds or until the results match. This method doesn't throw a TimeoutException

Parameters:
result - The result, needs to match the condition (using equals()).
timeout - Number of milliseconds to wait. A value of <= 0 means to wait forever

waitUntil

public void waitUntil(java.lang.Object result)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright ? 1998-2005 Bela Ban. All Rights Reserved.