org.jgroups.util

Class CondVar

public class CondVar extends 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(String name, Object cond)
CondVar(String name, Object cond, Object lock)
Method Summary
Objectget()
ObjectgetLock()
voidset(Object result)
Sets the result
StringtoString()
voidwaitUntil(Object result, long timeout)
Waits until the condition matches the expected result.
voidwaitUntil(Object result)
voidwaitUntilWithTimeout(Object result, long timeout)
Waits until the condition matches the expected result.

Constructor Detail

CondVar

public CondVar(String name, Object cond)

CondVar

public CondVar(String name, Object cond, Object lock)

Method Detail

get

public Object get()

getLock

public Object getLock()

set

public void set(Object result)
Sets the result

toString

public String toString()

waitUntil

public void waitUntil(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(Object result)

waitUntilWithTimeout

public void waitUntilWithTimeout(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.

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

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