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