1.dispatch队列时,只下发progress状态的请求

2.filecache trim时,在主线程中不读取文件,减少主线程逻辑开销

Signed-off-by: madixin <madixin@huawei.com>
This commit is contained in:
madixin 2024-04-29 09:31:23 +08:00
parent d152713556
commit 225754b15d
2 changed files with 12 additions and 6 deletions

View File

@ -201,9 +201,15 @@ export class ImageKnifeDispatcher {
}
dispatchNextJob() {
let request = this.jobQueue.pop()
if (request !== undefined) {
this.executeJob(request)
while (true) {
let request = this.jobQueue.pop()
if (request === undefined){
break// 队列已无任务
}
else if (request.requestState === ImageKnifeRequestState.PROGRESS) {
this.executeJob(request)
break
}
}
}

View File

@ -204,10 +204,10 @@ export class FileCache {
break
}
let delkey = this.lruCache.keys()[0]
let data: ArrayBuffer | undefined = FileUtils.getInstance().readFileSync(this.path + delkey)
if (data !== undefined) {
let remove: number | undefined = this.lruCache.remove(this.lruCache.keys()[0])
if (remove !== undefined) {
FileUtils.getInstance().deleteFile(this.path + delkey)
this.removeMemorySize(data)
this.removeMemorySize(remove)
}
this.lruCache.remove(delkey)
}