am 82574734: Merge "Create DictionaryStats in executor."

* commit '825747348b2fdc33d9593afd5ff29dbe9587524d':
  Create DictionaryStats in executor.
This commit is contained in:
Keisuke Kuroyanagi 2014-09-22 02:51:28 +00:00 committed by Android Git Automerger
commit a890979a23

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