This commit is contained in:
Shikhar Bhushan
2010-03-02 00:07:00 +01:00
parent dea4ad4895
commit 80d5395a29
2 changed files with 11 additions and 6 deletions

View File

@@ -31,7 +31,8 @@ import java.util.concurrent.locks.ReentrantLock;
* *
* @see Future * @see Future
*/ */
public class Event<T extends Exception> extends Future<Boolean, T> { public class Event<T extends Exception>
extends Future<Boolean, T> {
/** /**
* Creates this event with given {@code name} and exception {@code chainer}. Allocates a new {@link * Creates this event with given {@code name} and exception {@code chainer}. Allocates a new {@link
@@ -65,7 +66,8 @@ public class Event<T extends Exception> extends Future<Boolean, T> {
* *
* @throws T if another thread meanwhile informs this event of an error * @throws T if another thread meanwhile informs this event of an error
*/ */
public void await() throws T { public void await()
throws T {
super.get(); super.get();
} }
@@ -73,11 +75,12 @@ public class Event<T extends Exception> extends Future<Boolean, T> {
* Await this event to have a definite {@code true} or {@code false} value, for {@code timeout} seconds. * Await this event to have a definite {@code true} or {@code false} value, for {@code timeout} seconds.
* *
* @param timeout timeout in seconds * @param timeout timeout in seconds
* @param unit * @param unit the time unit
* *
* @throws T if another thread meanwhile informs this event of an error, or timeout expires * @throws T if another thread meanwhile informs this event of an error, or timeout expires
*/ */
public void await(long timeout, TimeUnit unit) throws T { public void await(long timeout, TimeUnit unit)
throws T {
super.get(timeout, unit); super.get(timeout, unit);
} }

View File

@@ -116,7 +116,8 @@ public class Future<V, T extends Exception> {
* *
* @throws T in case another thread informs the future of an error meanwhile * @throws T in case another thread informs the future of an error meanwhile
*/ */
public V get() throws T { public V get()
throws T {
return get(0, TimeUnit.SECONDS); return get(0, TimeUnit.SECONDS);
} }
@@ -130,7 +131,8 @@ public class Future<V, T extends Exception> {
* *
* @throws T in case another thread informs the future of an error meanwhile, or the timeout expires * @throws T in case another thread informs the future of an error meanwhile, or the timeout expires
*/ */
public V get(long timeout, TimeUnit unit) throws T { public V get(long timeout, TimeUnit unit)
throws T {
lock(); lock();
try { try {
if (pendingEx != null) if (pendingEx != null)