|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.spy.SpyObject
net.spy.concurrent.SynchronizationObject<T>
public class SynchronizationObject<T>
Object that will wait until a predicate determines that the value has been set to a particular value. Note that the predicate is not guaranteed to see every value change. It is quite likely that changes will be missed when the value is changing rapidly.
| Nested Class Summary | |
|---|---|
static interface |
SynchronizationObject.Predicate<T>
Synchronization object predicate for evaluation in waitUntilTrue. |
| Constructor Summary | |
|---|---|
SynchronizationObject(T o)
Construct a synchronization object on the given object. |
|
| Method Summary | |
|---|---|
T |
get()
Get the current value of this lock. |
T |
set(T o)
Set a new value and signal anyone listening for a value change. |
String |
toString()
String this SynchronizationObject. |
void |
waitUntilEquals(T val,
long timeout,
TimeUnit timeunit)
Wait for the contained object to become equal to the provided value. |
void |
waitUntilNotNull(long timeout,
TimeUnit timeunit)
Wait for the contained object to become non-null. |
void |
waitUntilTrue(SynchronizationObject.Predicate<T> p,
long timeout,
TimeUnit timeunit)
Wait for the given predicate to become true in respect to the contained object. |
| Methods inherited from class net.spy.SpyObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SynchronizationObject(T o)
| Method Detail |
|---|
public T get()
public T set(T o)
public String toString()
toString in class Object
public void waitUntilTrue(SynchronizationObject.Predicate<T> p,
long timeout,
TimeUnit timeunit)
throws InterruptedException,
TimeoutException
p - the predicatetimeout - how long to wait for this condition to become truetimeunit - the time unit for the timeout
InterruptedException
TimeoutException - if a timeout occurs before the condition
becomes true
public void waitUntilNotNull(long timeout,
TimeUnit timeunit)
throws InterruptedException,
TimeoutException
timeout - how long to wait for this condition to become truetimeunit - the time unit for the timeout
InterruptedException
TimeoutException - if a timeout occurs before the condition
becomes true
public void waitUntilEquals(T val,
long timeout,
TimeUnit timeunit)
throws InterruptedException,
TimeoutException
val - the value to wait fortimeout - how long to wait for this condition to become truetimeunit - the time unit for the timeout
InterruptedException
TimeoutException - if a timeout occurs before the condition
becomes true
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||