aboutsummaryrefslogtreecommitdiffstats
path: root/AndroidAsync/src/com/koushikdutta/async/future
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2013-09-10 20:29:35 -0700
committerKoushik Dutta <koushd@gmail.com>2013-09-10 20:29:35 -0700
commitc7fbf81aa1d58b288fe42ce4569a3ca8c5300016 (patch)
tree512612f6154f899f36a588a74f2e44d7fff512f2 /AndroidAsync/src/com/koushikdutta/async/future
parent18be9ef5afce92664f0a358dfcf3c9507286ebda (diff)
downloadAndroidAsync-c7fbf81aa1d58b288fe42ce4569a3ca8c5300016.tar.gz
AndroidAsync-c7fbf81aa1d58b288fe42ce4569a3ca8c5300016.tar.bz2
AndroidAsync-c7fbf81aa1d58b288fe42ce4569a3ca8c5300016.zip
Fix ups for Range requests.
Fix double onEnd call. Simplify SimpleFuture to allow returning of a result and an exception (WIP) Change-Id: I03ad9ae5b9f7a351db90e44f623acc61d1ff4aeb
Diffstat (limited to 'AndroidAsync/src/com/koushikdutta/async/future')
-rw-r--r--AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java22
1 files changed, 6 insertions, 16 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java b/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java
index e24f22b..e4ada4c 100644
--- a/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java
+++ b/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java
@@ -94,25 +94,21 @@ public class SimpleFuture<T> extends SimpleCancellable implements DependentFutur
Exception exception;
public boolean setComplete(Exception e) {
- FutureCallback<T> callback;
- synchronized (this) {
- if (!super.setComplete())
- return false;
- exception = e;
- releaseWaiterLocked();
- callback = handleCompleteLocked();
- }
- handleCallbackUnlocked(callback);
- return true;
+ return setComplete(e, null);
}
T result;
public boolean setComplete(T value) {
+ return setComplete(null, value);
+ }
+
+ public boolean setComplete(Exception e, T value) {
FutureCallback<T> callback;
synchronized (this) {
if (!super.setComplete())
return false;
result = value;
+ exception = e;
releaseWaiterLocked();
callback = handleCompleteLocked();
}
@@ -120,12 +116,6 @@ public class SimpleFuture<T> extends SimpleCancellable implements DependentFutur
return true;
}
- public boolean setComplete(Exception e, T value) {
- if (e != null)
- return setComplete(e);
- return setComplete(value);
- }
-
public FutureCallback<T> getCompletionCallback() {
return new FutureCallback<T>() {
@Override