Create DictionaryStats in executor.

Bug: 16553957
Change-Id: Ie4e9a6ee67f90ba0086af2075068e078efc7f189
This commit is contained in:
Keisuke Kuroyanagi 2014-09-22 10:25:51 +09:00
parent f88ec161e9
commit c724864c61

View file

@ -27,6 +27,7 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.WordProperty; import com.android.inputmethod.latin.makedict.WordProperty;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion; import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
import com.android.inputmethod.latin.utils.AsyncResultHolder;
import com.android.inputmethod.latin.utils.CombinedFormatUtils; import com.android.inputmethod.latin.utils.CombinedFormatUtils;
import com.android.inputmethod.latin.utils.DistracterFilter; import com.android.inputmethod.latin.utils.DistracterFilter;
import com.android.inputmethod.latin.utils.ExecutorUtils; import com.android.inputmethod.latin.utils.ExecutorUtils;
@ -645,13 +646,15 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
public DictionaryStats getDictionaryStats() { public DictionaryStats getDictionaryStats() {
reloadDictionaryIfRequired(); reloadDictionaryIfRequired();
mLock.readLock().lock(); final AsyncResultHolder<DictionaryStats> result = new AsyncResultHolder<>();
try { asyncExecuteTaskWithLock(mLock.readLock(), mDictName /* executorName */, new Runnable() {
// TODO: Get stats form the dictionary. @Override
return new DictionaryStats(mLocale, mDictName, mDictFile); public void run() {
} finally { // TODO: Get stats from the dictionary.
mLock.readLock().unlock(); result.set(new DictionaryStats(mLocale, mDictName, mDictFile));
} }
});
return result.get(null /* defaultValue */, TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS);
} }
@UsedForTesting @UsedForTesting