aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-06-07 12:33:33 +0900
committerJean Chalard <jchalard@google.com>2012-06-07 12:56:45 +0900
commit769cecf7e79dc6e2a98e527bdb9943bef9a42396 (patch)
treedb2f6c26a02fb87821f07248e079e15f5e7b5302 /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
parent69b4e411e1666a7a4abed72ab5484878b24cba35 (diff)
downloadlatinime-769cecf7e79dc6e2a98e527bdb9943bef9a42396.tar.gz
latinime-769cecf7e79dc6e2a98e527bdb9943bef9a42396.tar.xz
latinime-769cecf7e79dc6e2a98e527bdb9943bef9a42396.zip
Close spell-checking dictionaries in a background thread
Bug: 6584677 Change-Id: Ifd9b0f995f4e0cf4d35a7ecde767826ab976f0b8
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java45
1 files changed, 25 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 8128779a4..88efc5a85 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -372,27 +372,32 @@ public class AndroidSpellCheckerService extends SpellCheckerService
mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries;
mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
- for (DictionaryPool pool : oldPools.values()) {
- pool.close();
- }
- for (Dictionary dict : oldUserDictionaries.values()) {
- dict.close();
- }
- for (Dictionary dict : oldWhitelistDictionaries.values()) {
- dict.close();
- }
- synchronized (mUseContactsLock) {
- if (null != mContactsDictionary) {
- // The synchronously loaded contacts dictionary should have been in one
- // or several pools, but it is shielded against multiple closing and it's
- // safe to call it several times.
- final Dictionary dictToClose = mContactsDictionary;
- // TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY is no
- // longer needed
- mContactsDictionary = null;
- dictToClose.close();
+ new Thread("spellchecker_close_dicts") {
+ @Override
+ public void run() {
+ for (DictionaryPool pool : oldPools.values()) {
+ pool.close();
+ }
+ for (Dictionary dict : oldUserDictionaries.values()) {
+ dict.close();
+ }
+ for (Dictionary dict : oldWhitelistDictionaries.values()) {
+ dict.close();
+ }
+ synchronized (mUseContactsLock) {
+ if (null != mContactsDictionary) {
+ // The synchronously loaded contacts dictionary should have been in one
+ // or several pools, but it is shielded against multiple closing and it's
+ // safe to call it several times.
+ final Dictionary dictToClose = mContactsDictionary;
+ // TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY
+ // is no longer needed
+ mContactsDictionary = null;
+ dictToClose.close();
+ }
+ }
}
- }
+ }.start();
}
private DictionaryPool getDictionaryPool(final String locale) {