aboutsummaryrefslogtreecommitdiffstats
path: root/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2015-01-19 12:46:40 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-01-19 12:46:40 +0000
commitaab56800fcb95e9b1a2d653588b14158080cc6b4 (patch)
tree7365392c3ea77742021cf187acfd465f9bb774ab /guava/src/com/google/common/util/concurrent/AbstractIdleService.java
parent6fa98dbaae182b511fbeb331e08f5fb827715ea8 (diff)
parent84fb43aa6a1e752487f2624055ff26b1b6b7c043 (diff)
downloadandroid_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.tar.gz
android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.tar.bz2
android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.zip
am 84fb43aa: Merge "Revert "Upgraded Guava to unmodified v14.0.1""
* commit '84fb43aa6a1e752487f2624055ff26b1b6b7c043': Revert "Upgraded Guava to unmodified v14.0.1"
Diffstat (limited to 'guava/src/com/google/common/util/concurrent/AbstractIdleService.java')
-rw-r--r--guava/src/com/google/common/util/concurrent/AbstractIdleService.java40
1 files changed, 10 insertions, 30 deletions
diff --git a/guava/src/com/google/common/util/concurrent/AbstractIdleService.java b/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
index 96a6ff3..504a6bc 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
@@ -37,7 +37,7 @@ public abstract class AbstractIdleService implements Service {
/* use AbstractService for state management */
private final Service delegate = new AbstractService() {
@Override protected final void doStart() {
- executor().execute(new Runnable() {
+ executor(State.STARTING).execute(new Runnable() {
@Override public void run() {
try {
startUp();
@@ -51,7 +51,7 @@ public abstract class AbstractIdleService implements Service {
}
@Override protected final void doStop() {
- executor().execute(new Runnable() {
+ executor(State.STOPPING).execute(new Runnable() {
@Override public void run() {
try {
shutDown();
@@ -65,9 +65,6 @@ public abstract class AbstractIdleService implements Service {
}
};
- /** Constructor for use by subclasses. */
- protected AbstractIdleService() {}
-
/** Start the service. */
protected abstract void startUp() throws Exception;
@@ -81,19 +78,22 @@ public abstract class AbstractIdleService implements Service {
* priority. The returned executor's {@link Executor#execute(Runnable)
* execute()} method is called when this service is started and stopped,
* and should return promptly.
+ *
+ * @param state {@link Service.State#STARTING} or
+ * {@link Service.State#STOPPING}, used by the default implementation for
+ * naming the thread
*/
- protected Executor executor() {
- final State state = state();
+ protected Executor executor(final State state) {
return new Executor() {
@Override
public void execute(Runnable command) {
- MoreExecutors.newThread(serviceName() + " " + state, command).start();
+ new Thread(command, getServiceName() + " " + state).start();
}
};
}
@Override public String toString() {
- return serviceName() + " [" + state() + "]";
+ return getServiceName() + " [" + state() + "]";
}
// We override instead of using ForwardingService so that these can be final.
@@ -122,27 +122,7 @@ public abstract class AbstractIdleService implements Service {
return delegate.stopAndWait();
}
- /**
- * @since 13.0
- */
- @Override public final void addListener(Listener listener, Executor executor) {
- delegate.addListener(listener, executor);
- }
-
- /**
- * @since 14.0
- */
- @Override public final Throwable failureCause() {
- return delegate.failureCause();
- }
-
- /**
- * Returns the name of this service. {@link AbstractIdleService} may include the name in debugging
- * output.
- *
- * @since 14.0
- */
- protected String serviceName() {
+ private String getServiceName() {
return getClass().getSimpleName();
}
}