am 82574734: Merge "Create DictionaryStats in executor."

* commit '825747348b2fdc33d9593afd5ff29dbe9587524d':
  Create DictionaryStats in executor.
main
Keisuke Kuroyanagi 2014-09-22 02:51:28 +00:00 committed by Android Git Automerger
commit a890979a23
1 changed files with 10 additions and 7 deletions

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