diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-05-29 14:53:00 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-05-29 14:53:00 -0700 |
commit | 5ce041a4139d55a112c8e80abfa77c6115164a9b (patch) | |
tree | c02519707b3f022985529a316600d275d86594d9 /AndroidAsync/src/com/koushikdutta/async/future | |
parent | c2b06c0b5aefffb8ea3ab14c6055b21c4d7f3e6b (diff) | |
download | AndroidAsync-5ce041a4139d55a112c8e80abfa77c6115164a9b.tar.gz AndroidAsync-5ce041a4139d55a112c8e80abfa77c6115164a9b.tar.bz2 AndroidAsync-5ce041a4139d55a112c8e80abfa77c6115164a9b.zip |
Change spelling on SimpleCancellable to match the Java spelling.
Diffstat (limited to 'AndroidAsync/src/com/koushikdutta/async/future')
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/future/Continuation.java | 2 | ||||
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/future/SimpleCancellable.java (renamed from AndroidAsync/src/com/koushikdutta/async/future/SimpleCancelable.java) | 26 | ||||
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java | 7 |
3 files changed, 24 insertions, 11 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/future/Continuation.java b/AndroidAsync/src/com/koushikdutta/async/future/Continuation.java index d1873c6..11ff246 100644 --- a/AndroidAsync/src/com/koushikdutta/async/future/Continuation.java +++ b/AndroidAsync/src/com/koushikdutta/async/future/Continuation.java @@ -5,7 +5,7 @@ import com.koushikdutta.async.callback.ContinuationCallback; import java.util.LinkedList; -public class Continuation extends SimpleCancelable implements ContinuationCallback, Runnable, Cancellable { +public class Continuation extends SimpleCancellable implements ContinuationCallback, Runnable, Cancellable { CompletedCallback callback; Runnable cancelCallback; diff --git a/AndroidAsync/src/com/koushikdutta/async/future/SimpleCancelable.java b/AndroidAsync/src/com/koushikdutta/async/future/SimpleCancellable.java index ad43dd8..2550b60 100644 --- a/AndroidAsync/src/com/koushikdutta/async/future/SimpleCancelable.java +++ b/AndroidAsync/src/com/koushikdutta/async/future/SimpleCancellable.java @@ -1,19 +1,35 @@ package com.koushikdutta.async.future; -public class SimpleCancelable implements DependentCancellable { +public class SimpleCancellable implements DependentCancellable { boolean complete; @Override public boolean isDone() { return complete; } - + + protected void cancelCleanup() { + } + + protected void cleanup() { + } + + protected void completeCleanup() { + } + public boolean setComplete() { synchronized (this) { if (canceled) return false; + if (complete) { + // don't allow a Cancellable to complete twice... + assert false; + return true; + } complete = true; parent = null; } + completeCleanup(); + cleanup(); return true; } @@ -32,13 +48,15 @@ public class SimpleCancelable implements DependentCancellable { } if (parent != null) parent.cancel(); + cancelCleanup(); + cleanup(); return true; } boolean canceled; private Cancellable parent; @Override - public SimpleCancelable setParent(Cancellable parent) { + public SimpleCancellable setParent(Cancellable parent) { synchronized (this) { if (!isDone()) this.parent = parent; @@ -51,7 +69,7 @@ public class SimpleCancelable implements DependentCancellable { return canceled || (parent != null && parent.isCancelled()); } - public static final Cancellable COMPLETED = new SimpleCancelable() { + public static final Cancellable COMPLETED = new SimpleCancellable() { { setComplete(); } diff --git a/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java b/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java index f13daf7..6aa4fbc 100644 --- a/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java +++ b/AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java @@ -6,23 +6,18 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import com.koushikdutta.async.AsyncServer.AsyncSemaphore; -import com.koushikdutta.async.callback.ResultCallback; -public class SimpleFuture<T> extends SimpleCancelable implements DependentFuture<T> { +public class SimpleFuture<T> extends SimpleCancellable implements DependentFuture<T> { @Override 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(); } |