|
|||||||||
| Home >> All >> org >> jgroups >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jgroups.util
Class Promise

java.lang.Objectorg.jgroups.util.Promise
- public class Promise
- extends java.lang.Object
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.
| Field Summary | |
(package private) boolean |
hasResult
|
(package private) java.lang.Object |
result
|
| Constructor Summary | |
Promise()
|
|
| Method Summary | |
private java.lang.Object |
_getResultWithTimeout(long timeout)
Blocks until a result is available, or timeout milliseconds have elapsed. |
(package private) void |
doWait()
|
(package private) void |
doWait(long timeout)
|
java.lang.Object |
getResult()
|
java.lang.Object |
getResult(long timeout)
Returns the result, but never throws a TimeoutException; returns null instead. |
java.lang.Object |
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(java.lang.Object obj)
Sets the result and notifies any threads waiting for it |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
result
java.lang.Object result
hasResult
boolean hasResult
| Constructor Detail |
Promise
public Promise()
| Method Detail |
getResultWithTimeout
public java.lang.Object getResultWithTimeout(long timeout) throws org.jgroups.TimeoutException
- Blocks until a result is available, or timeout milliseconds have elapsed
_getResultWithTimeout
private java.lang.Object _getResultWithTimeout(long timeout) throws org.jgroups.TimeoutException
- Blocks until a result is available, or timeout milliseconds have elapsed. Needs to be called with
a lock held on 'this'
getResult
public java.lang.Object getResult()
getResult
public java.lang.Object getResult(long timeout)
- Returns the result, but never throws a TimeoutException; returns null instead.
doWait
void doWait()
doWait
void doWait(long timeout)
hasResult
public boolean hasResult()
- Checks whether result is available. Does not block.
setResult
public void setResult(java.lang.Object obj)
- Sets the result and notifies any threads
waiting for it
reset
public void reset()
- Causes all waiting threads to return
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
|
|||||||||
| Home >> All >> org >> jgroups >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.jgroups.util.Promise