forked from google/guice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request google#919 from google/moe_writing_branch_from_156…
…c8cc762fab971efb727c7ab107fa243be2fc9 Merge internal changes
- Loading branch information
Showing
3 changed files
with
21 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
package com.google.inject.service; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.common.util.concurrent.Runnables; | ||
|
||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.ExecutorService; | ||
|
@@ -31,6 +30,10 @@ | |
* @author [email protected] (Dhanji R. Prasanna) | ||
*/ | ||
public abstract class AsyncService implements Service { | ||
private static final Runnable DO_NOTHING = new Runnable() { | ||
@Override public void run() {} | ||
}; | ||
|
||
private final ExecutorService executor; | ||
|
||
private volatile State state; | ||
|
@@ -45,7 +48,7 @@ public synchronized final Future<State> start() { | |
|
||
// Starts are idempotent. | ||
if (state == State.STARTED) { | ||
return new FutureTask<State>(Runnables.doNothing(), State.STARTED); | ||
return new FutureTask<State>(DO_NOTHING, State.STARTED); | ||
} | ||
|
||
return executor.submit(new Callable<State>() { | ||
|
@@ -70,7 +73,7 @@ public synchronized final Future<State> stop() { | |
|
||
// Likewise, stops are idempotent. | ||
if (state == State.STOPPED) { | ||
return new FutureTask<State>(Runnables.doNothing(), State.STOPPED); | ||
return new FutureTask<State>(DO_NOTHING, State.STOPPED); | ||
} | ||
|
||
return executor.submit(new Callable<State>() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters