aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
diff options
context:
space:
mode:
authorJatin Matani <jatinm@google.com>2015-02-09 12:22:47 -0800
committerJatin Matani <jatinm@google.com>2015-02-11 16:29:14 -0800
commit4084fa5caeee09ef7993957c5e922dab14c57f3f (patch)
treeb904b243d8ab05d6dc3e83411713d0b2a55c0014 /java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
parent5254c01d4cc024527479d4dc5fab2ed2516c395c (diff)
downloadlatinime-4084fa5caeee09ef7993957c5e922dab14c57f3f.tar.gz
latinime-4084fa5caeee09ef7993957c5e922dab14c57f3f.tar.xz
latinime-4084fa5caeee09ef7993957c5e922dab14c57f3f.zip
Refactor content provider code from ContactsDict
Break contacts binary dictionary into two parts - one that talks to contacts content provider and maintains local state. Includes a manager class and a content observer - other one that just manages the dict code. Change-Id: Ie8f89ac9ce174c803ff3168ee0bee5cbe7721d5b
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java b/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
index e77f6fd40..50be16072 100644
--- a/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
@@ -21,13 +21,14 @@ import com.android.inputmethod.annotations.UsedForTesting;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
/**
* Utilities to manage executors.
*/
public class ExecutorUtils {
- static final ConcurrentHashMap<String, ExecutorService> sExecutorMap =
+ static final ConcurrentHashMap<String, ScheduledExecutorService> sExecutorMap =
new ConcurrentHashMap<>();
private static class ThreadFactoryWithId implements ThreadFactory {
@@ -46,13 +47,14 @@ public class ExecutorUtils {
/**
* Gets the executor for the given id.
*/
- public static ExecutorService getExecutor(final String id) {
- ExecutorService executor = sExecutorMap.get(id);
+ public static ScheduledExecutorService getExecutor(final String id) {
+ ScheduledExecutorService executor = sExecutorMap.get(id);
if (executor == null) {
synchronized (sExecutorMap) {
executor = sExecutorMap.get(id);
if (executor == null) {
- executor = Executors.newSingleThreadExecutor(new ThreadFactoryWithId(id));
+ executor = Executors.newSingleThreadScheduledExecutor(
+ new ThreadFactoryWithId(id));
sExecutorMap.put(id, executor);
}
}
@@ -66,7 +68,7 @@ public class ExecutorUtils {
@UsedForTesting
public static void shutdownAllExecutors() {
synchronized (sExecutorMap) {
- for (final ExecutorService executor : sExecutorMap.values()) {
+ for (final ScheduledExecutorService executor : sExecutorMap.values()) {
executor.execute(new Runnable() {
@Override
public void run() {