diff options
author | 2013-09-29 22:18:00 -0700 | |
---|---|---|
committer | 2013-09-29 22:18:00 -0700 | |
commit | 0aaf42b4caa6956c23462a36a8278e9acb8514b1 (patch) | |
tree | d9823ee6aea67eb62b09e3653c4a82729f1d9f57 /java/src | |
parent | f2800fc6f44521f0594a4c29441bdf04d14341d8 (diff) | |
parent | c18510049a3422c88ed3ab3bbc64944c94a611fd (diff) | |
download | latinime-0aaf42b4caa6956c23462a36a8278e9acb8514b1.tar.gz latinime-0aaf42b4caa6956c23462a36a8278e9acb8514b1.tar.xz latinime-0aaf42b4caa6956c23462a36a8278e9acb8514b1.zip |
am c1851004: Prepare dictionary decay.
* commit 'c18510049a3422c88ed3ab3bbc64944c94a611fd':
Prepare dictionary decay.
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 14 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 6ec7aeec3..29c6c0451 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -115,7 +115,7 @@ public final class BinaryDictionary extends Dictionary { private static native long openNative(String sourceDir, long dictOffset, long dictSize, boolean isUpdatable); private static native void flushNative(long dict, String filePath); - private static native boolean needsToRunGCNative(long dict); + private static native boolean needsToRunGCNative(long dict, boolean mindsBlockByGC); private static native void flushWithGCNative(long dict, String filePath); private static native void closeNative(long dict); private static native int getProbabilityNative(long dict, int[] word); @@ -270,7 +270,7 @@ public final class BinaryDictionary extends Dictionary { } private void runGCIfRequired() { - if (needsToRunGCNative(mNativeDict)) { + if (needsToRunGC(true /* mindsBlockByGC */)) { flushWithGC(); } } @@ -326,9 +326,15 @@ public final class BinaryDictionary extends Dictionary { reopen(); } - public boolean needsToRunGC() { + /** + * Checks whether GC is needed to run or not. + * @param mindsBlockByGC Whether to mind operations blocked by GC. We don't need to care about + * the blocking in some situations such as in idle time or just before closing. + * @return whether GC is needed to run or not. + */ + public boolean needsToRunGC(final boolean mindsBlockByGC) { if (!isValidDictionary()) return false; - return needsToRunGCNative(mNativeDict); + return needsToRunGCNative(mNativeDict, mindsBlockByGC); } @UsedForTesting diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index cbba3f845..2d1ca51e2 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -505,7 +505,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { BinaryDictionary.createEmptyDictFile(file.getAbsolutePath(), DICTIONARY_FORMAT_VERSION, getHeaderAttributeMap()); } else { - if (mBinaryDictionary.needsToRunGC()) { + if (mBinaryDictionary.needsToRunGC(false /* mindsBlockByGC */)) { mBinaryDictionary.flushWithGC(); } else { mBinaryDictionary.flush(); |