mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-05 06:10:14 +00:00
no need for special lock object
This commit is contained in:
parent
9709c0d0a2
commit
900dfa1b9c
1 changed files with 3 additions and 6 deletions
|
@ -58,9 +58,6 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
@Volatile
|
@Volatile
|
||||||
private var mLatchForWaitingLoadingMainDictionaries = CountDownLatch(0)
|
private var mLatchForWaitingLoadingMainDictionaries = CountDownLatch(0)
|
||||||
|
|
||||||
// To synchronize assigning mDictionaryGroup to ensure closing dictionaries.
|
|
||||||
private val mLock = Any()
|
|
||||||
|
|
||||||
// The library does not deal well with ngram history for auto-capitalized words, so we adjust
|
// The library does not deal well with ngram history for auto-capitalized words, so we adjust
|
||||||
// the ngram context to store next word suggestions for such cases.
|
// the ngram context to store next word suggestions for such cases.
|
||||||
// todo: this is awful, find a better solution / workaround
|
// todo: this is awful, find a better solution / workaround
|
||||||
|
@ -159,7 +156,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
|
|
||||||
// Replace Dictionaries.
|
// Replace Dictionaries.
|
||||||
val oldDictionaryGroups: List<DictionaryGroup>
|
val oldDictionaryGroups: List<DictionaryGroup>
|
||||||
synchronized(mLock) {
|
synchronized(this) {
|
||||||
oldDictionaryGroups = dictionaryGroups
|
oldDictionaryGroups = dictionaryGroups
|
||||||
dictionaryGroups = newDictionaryGroups
|
dictionaryGroups = newDictionaryGroups
|
||||||
if (hasAtLeastOneUninitializedMainDictionary()) {
|
if (hasAtLeastOneUninitializedMainDictionary()) {
|
||||||
|
@ -252,7 +249,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
if (dictionaryGroup.getDict(Dictionary.TYPE_MAIN)?.isInitialized == true) null
|
if (dictionaryGroup.getDict(Dictionary.TYPE_MAIN)?.isInitialized == true) null
|
||||||
else dictionaryGroup to createMainDictionary(context, it)
|
else dictionaryGroup to createMainDictionary(context, it)
|
||||||
}
|
}
|
||||||
synchronized(mLock) {
|
synchronized(this) {
|
||||||
dictGroupsWithNewMainDict.forEach { (dictGroup, mainDict) ->
|
dictGroupsWithNewMainDict.forEach { (dictGroup, mainDict) ->
|
||||||
dictGroup.setMainDict(mainDict)
|
dictGroup.setMainDict(mainDict)
|
||||||
}
|
}
|
||||||
|
@ -265,7 +262,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
|
|
||||||
override fun closeDictionaries() {
|
override fun closeDictionaries() {
|
||||||
val dictionaryGroupsToClose: List<DictionaryGroup>
|
val dictionaryGroupsToClose: List<DictionaryGroup>
|
||||||
synchronized(mLock) {
|
synchronized(this) {
|
||||||
dictionaryGroupsToClose = dictionaryGroups
|
dictionaryGroupsToClose = dictionaryGroups
|
||||||
dictionaryGroups = listOf(DictionaryGroup())
|
dictionaryGroups = listOf(DictionaryGroup())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue