diff options
author | 2012-06-06 21:50:38 -0700 | |
---|---|---|
committer | 2012-06-06 21:50:38 -0700 | |
commit | eead5492615f0b05ef85ca1f88d3a41ce3f8d496 (patch) | |
tree | e011699d95be0e67a9863b7d5fd46cf9886a5abd /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | |
parent | c27646cd2705786b33e23edd7f3902e40afecab8 (diff) | |
parent | 769cecf7e79dc6e2a98e527bdb9943bef9a42396 (diff) | |
download | latinime-eead5492615f0b05ef85ca1f88d3a41ce3f8d496.tar.gz latinime-eead5492615f0b05ef85ca1f88d3a41ce3f8d496.tar.xz latinime-eead5492615f0b05ef85ca1f88d3a41ce3f8d496.zip |
am 769cecf7: Close spell-checking dictionaries in a background thread
* commit '769cecf7e79dc6e2a98e527bdb9943bef9a42396':
Close spell-checking dictionaries in a background thread
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 45 |
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) { |