diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-05-26 16:56:30 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-05-26 16:56:30 -0700 |
commit | b9b380e51487a687a7bdddb116639b44f4b5cc94 (patch) | |
tree | 86959c5936877f79563d3fe27da81406c163ea54 /AndroidAsync/src/com/koushikdutta/async/future | |
parent | 59447b25f095b16c9385c7308db832d31e01d08b (diff) | |
download | AndroidAsync-b9b380e51487a687a7bdddb116639b44f4b5cc94.tar.gz AndroidAsync-b9b380e51487a687a7bdddb116639b44f4b5cc94.tar.bz2 AndroidAsync-b9b380e51487a687a7bdddb116639b44f4b5cc94.zip |
fix thread affinity/invoke and cancellation issues in http client.
Diffstat (limited to 'AndroidAsync/src/com/koushikdutta/async/future')
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java b/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java index 010ac2f..0ec3ecc 100644 --- a/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java +++ b/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java @@ -13,12 +13,16 @@ public class SimpleFuture<T> extends SimpleCancelable implements DependentFuture public boolean cancel(boolean mayInterruptIfRunning) { return cancel(); } + + protected void cancelCleanup() { + } @Override public boolean cancel() { if (super.cancel()) { synchronized (this) { exception = new CancellationException(); + cancelCleanup(); if (waiter != null) waiter.release(); } @@ -32,9 +36,7 @@ public class SimpleFuture<T> extends SimpleCancelable implements DependentFuture @Override public T get() throws InterruptedException, ExecutionException { synchronized (this) { - if (isCancelled()) - return null; - if (isDone()) + if (isCancelled() || isDone()) return getResult(); if (waiter == null) waiter = new AsyncSemaphore(); @@ -52,9 +54,7 @@ public class SimpleFuture<T> extends SimpleCancelable implements DependentFuture @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { synchronized (this) { - if (isCancelled()) - throw new ExecutionException(new CancellationException()); - if (isDone()) + if (isCancelled() || isDone()) return getResult(); if (waiter == null) waiter = new AsyncSemaphore(); |