|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jgit.storage.dht.Sync<T>
T
- type of value object.public abstract class Sync<T>
Helper to implement a synchronous method in terms of an asynchronous one.
Implementors can use this type to wait for an asynchronous computation to complete on a background thread by passing the Sync instance as though it were the AsyncCallback:
Sync<T> sync = Sync.create(); async(..., sync); return sync.get(timeout, TimeUnit.MILLISECONDS);
Constructor Summary | |
---|---|
Sync()
|
Method Summary | ||
---|---|---|
static
|
create()
Helper method to create a new sync object. |
|
abstract T |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Wait for the asynchronous operation to complete. |
|
T |
get(Timeout timeout)
Wait for the asynchronous operation to complete. |
|
static
|
none()
Singleton callback that ignores onSuccess, onFailure. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.jgit.storage.dht.AsyncCallback |
---|
onFailure, onSuccess |
Constructor Detail |
---|
public Sync()
Method Detail |
---|
public static <T> Sync<T> create()
T
- type of value object.
public static <T> Sync<T> none()
T
- type of value object.
public T get(Timeout timeout) throws DhtException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
To prevent application deadlock, waiting can only be performed with the supplied timeout.
timeout
- amount of time to wait before failing.
DhtException
- the asynchronous operation failed.
java.lang.InterruptedException
- the current thread was interrupted before the operation
completed.
java.util.concurrent.TimeoutException
- the timeout elapsed before the operation completed.public abstract T get(long timeout, java.util.concurrent.TimeUnit unit) throws DhtException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
To prevent application deadlock, waiting can only be performed with the supplied timeout.
timeout
- amount of time to wait before failing.unit
- units of timeout
. For example
TimeUnit.MILLISECONDS
.
DhtException
- the asynchronous operation failed.
java.lang.InterruptedException
- the current thread was interrupted before the operation
completed.
java.util.concurrent.TimeoutException
- the timeout elapsed before the operation completed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |