LMI // Apply GCD to all functions loading user dictionaries.
This commit is contained in:
parent
d5ce4f29ad
commit
9a58893585
|
@ -129,62 +129,76 @@ extension vChewingLM {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 上述幾個函式不要加 Async,因為這些內容都被 LMMgr 負責用別的方法 Async 了、用 GCD 的多任務並行共結來完成。
|
||||||
|
|
||||||
public func loadUserPhrasesData(path: String, filterPath: String) {
|
public func loadUserPhrasesData(path: String, filterPath: String) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
if FileManager.default.isReadableFile(atPath: path) {
|
if FileManager.default.isReadableFile(atPath: path) {
|
||||||
lmUserPhrases.close()
|
self.lmUserPhrases.close()
|
||||||
lmUserPhrases.open(path)
|
self.lmUserPhrases.open(path)
|
||||||
vCLog("lmUserPhrases: \(lmUserPhrases.count) entries of data loaded from: \(path)")
|
vCLog("lmUserPhrases: \(self.lmUserPhrases.count) entries of data loaded from: \(path)")
|
||||||
} else {
|
} else {
|
||||||
vCLog("lmUserPhrases: File access failure: \(path)")
|
vCLog("lmUserPhrases: File access failure: \(path)")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
if FileManager.default.isReadableFile(atPath: filterPath) {
|
if FileManager.default.isReadableFile(atPath: filterPath) {
|
||||||
lmFiltered.close()
|
self.lmFiltered.close()
|
||||||
lmFiltered.open(filterPath)
|
self.lmFiltered.open(filterPath)
|
||||||
vCLog("lmFiltered: \(lmFiltered.count) entries of data loaded from: \(path)")
|
vCLog("lmFiltered: \(self.lmFiltered.count) entries of data loaded from: \(path)")
|
||||||
} else {
|
} else {
|
||||||
vCLog("lmFiltered: File access failure: \(path)")
|
vCLog("lmFiltered: File access failure: \(path)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func loadUserSymbolData(path: String) {
|
public func loadUserSymbolData(path: String) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
if FileManager.default.isReadableFile(atPath: path) {
|
if FileManager.default.isReadableFile(atPath: path) {
|
||||||
lmUserSymbols.close()
|
self.lmUserSymbols.close()
|
||||||
lmUserSymbols.open(path)
|
self.lmUserSymbols.open(path)
|
||||||
vCLog("lmUserSymbol: \(lmUserSymbols.count) entries of data loaded from: \(path)")
|
vCLog("lmUserSymbol: \(self.lmUserSymbols.count) entries of data loaded from: \(path)")
|
||||||
} else {
|
} else {
|
||||||
vCLog("lmUserSymbol: File access failure: \(path)")
|
vCLog("lmUserSymbol: File access failure: \(path)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func loadUserAssociatesData(path: String) {
|
public func loadUserAssociatesData(path: String) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
if FileManager.default.isReadableFile(atPath: path) {
|
if FileManager.default.isReadableFile(atPath: path) {
|
||||||
lmAssociates.close()
|
self.lmAssociates.close()
|
||||||
lmAssociates.open(path)
|
self.lmAssociates.open(path)
|
||||||
vCLog("lmAssociates: \(lmAssociates.count) entries of data loaded from: \(path)")
|
vCLog("lmAssociates: \(self.lmAssociates.count) entries of data loaded from: \(path)")
|
||||||
} else {
|
} else {
|
||||||
vCLog("lmAssociates: File access failure: \(path)")
|
vCLog("lmAssociates: File access failure: \(path)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func loadReplacementsData(path: String) {
|
public func loadReplacementsData(path: String) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
if FileManager.default.isReadableFile(atPath: path) {
|
if FileManager.default.isReadableFile(atPath: path) {
|
||||||
lmReplacements.close()
|
self.lmReplacements.close()
|
||||||
lmReplacements.open(path)
|
self.lmReplacements.open(path)
|
||||||
vCLog("lmReplacements: \(lmReplacements.count) entries of data loaded from: \(path)")
|
vCLog("lmReplacements: \(self.lmReplacements.count) entries of data loaded from: \(path)")
|
||||||
} else {
|
} else {
|
||||||
vCLog("lmReplacements: File access failure: \(path)")
|
vCLog("lmReplacements: File access failure: \(path)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func loadUserSCPCSequencesData(path: String) {
|
public func loadUserSCPCSequencesData(path: String) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
if FileManager.default.isReadableFile(atPath: path) {
|
if FileManager.default.isReadableFile(atPath: path) {
|
||||||
lmPlainBopomofo.close()
|
self.lmPlainBopomofo.close()
|
||||||
lmPlainBopomofo.open(path)
|
self.lmPlainBopomofo.open(path)
|
||||||
vCLog("lmPlainBopomofo: \(lmPlainBopomofo.count) entries of data loaded from: \(path)")
|
vCLog("lmPlainBopomofo: \(self.lmPlainBopomofo.count) entries of data loaded from: \(path)")
|
||||||
} else {
|
} else {
|
||||||
vCLog("lmPlainBopomofo: File access failure: \(path)")
|
vCLog("lmPlainBopomofo: File access failure: \(path)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - 核心函式(對外)
|
// MARK: - 核心函式(對外)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue