From 225754b15d5e71dfa0f95ac9f9a280262752048f Mon Sep 17 00:00:00 2001 From: madixin Date: Mon, 29 Apr 2024 09:31:23 +0800 Subject: [PATCH] =?UTF-8?q?1.dispatch=E9=98=9F=E5=88=97=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E4=B8=8B=E5=8F=91progress=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=202.filecache=20trim=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E4=B8=BB=E7=BA=BF=E7=A8=8B=E4=B8=AD=E4=B8=8D=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E6=96=87=E4=BB=B6=EF=BC=8C=E5=87=8F=E5=B0=91=E4=B8=BB?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E9=80=BB=E8=BE=91=E5=BC=80=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: madixin --- library/src/main/ets/ImageKnifeDispatcher.ets | 12 +++++++++--- library/src/main/ets/utils/FileCache.ets | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/src/main/ets/ImageKnifeDispatcher.ets b/library/src/main/ets/ImageKnifeDispatcher.ets index 2befcab..a2428fb 100644 --- a/library/src/main/ets/ImageKnifeDispatcher.ets +++ b/library/src/main/ets/ImageKnifeDispatcher.ets @@ -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 + } } } diff --git a/library/src/main/ets/utils/FileCache.ets b/library/src/main/ets/utils/FileCache.ets index 195a0ad..b55b334 100644 --- a/library/src/main/ets/utils/FileCache.ets +++ b/library/src/main/ets/utils/FileCache.ets @@ -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) }