|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgroups.util.Promise<T>
public class Promise<T>
Allows a thread to submit an asynchronous request and to wait for the result. The caller may choose to check for the result at a later time, or immediately and it may block or not. Both the caller and responder have to know the promise.
Constructor Summary | |
---|---|
Promise()
|
Method Summary | |
---|---|
java.util.concurrent.locks.Condition |
getCond()
|
java.util.concurrent.locks.Lock |
getLock()
|
T |
getResult()
|
T |
getResult(long timeout)
Returns the result, but never throws a TimeoutException; returns null instead. |
T |
getResultWithTimeout(long timeout)
Blocks until a result is available, or timeout milliseconds have elapsed |
boolean |
hasResult()
Checks whether result is available. |
void |
reset()
Causes all waiting threads to return |
void |
setResult(T obj)
Sets the result and notifies any threads waiting for it |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Promise()
Method Detail |
---|
public java.util.concurrent.locks.Lock getLock()
public java.util.concurrent.locks.Condition getCond()
public T getResultWithTimeout(long timeout) throws TimeoutException
timeout
-
TimeoutException
- If a timeout occurred (implies that timeout > 0)public T getResult()
public T getResult(long timeout)
timeout
-
public boolean hasResult()
public void setResult(T obj)
public void reset()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |