当前位置:首页>鸿蒙APP>JSyncQueue——一个开箱即用的鸿蒙异步任务同步队列

JSyncQueue——一个开箱即用的鸿蒙异步任务同步队列

  • 2026-02-02 09:06:41
JSyncQueue——一个开箱即用的鸿蒙异步任务同步队列

零、JSyncQueue

JSyncQueue 是一个开箱即用的鸿蒙异步任务同步队列。

项目地址:https://github.com/zincPower/JSyncQueue

一、JSyncQueue 有什么作用

在鸿蒙应用开发中,有时需要让多个异步任务按顺序执行,例如状态的转换处理,如果不加控制,会因为执行顺序混乱而产生一些莫名其妙的问题。 所以 JSyncQueue 提供了一个简洁的解决方案:

  • • 保证顺序执行:所有任务严格按照入队顺序执行,即使任务内部有异步操作也能保证顺序
  • • 两种执行模式:支持 "立即执行" 和 "延时执行" 两种模式,可以满足不同场景需求
  • • 两种任务类型:支持向同步队列添加 "Message 类型任务" 和 "Runnable 类型任务"
  • • 任务取消和管理:可随时取消指定任务或清空整个队列
  • • 获取任务结果:通过任务的 getResult() 获取执行结果

项目架构如下图所示:

二、如何安装 JSyncQueue

第一种方式: 在需要使用 JSyncQueue 的模块中运行以下命令

ohpm install jsyncqueue

第二种方式: 在需要使用 JSyncQueue 的模块 oh-package.json5 中添加以下依赖

{
"name":"sample",
"version":"1.0.0",
"description":"Please describe the basic information.",
"main":"",
"author":"",
"license":"",
"dependencies":{
"jsyncqueue":"1.0.0"// 添加这一行,请根据需要修改版本号
}
}

三、JSyncQueue API 介绍

3-1、JSyncQueue 类

构造函数

constructor(queueNamestring)

创建一个同步队列实例。

  • • queueName: 队列名称,用于标识和调试

方法

方法
参数
返回值
说明
post(runnable)runnable: (taskId: number) => Promise<Any>Task
立即执行闭包
postDelay(runnable, delay)runnable: (taskId: number) => Promise<Any>
delay: number
Task
延时 delay 毫秒执行闭包
sendMessage(message)message: MessageTask
立即发送消息
sendMessageDelay(message, delay)message: Message
delay: number
Task
延时 delay 毫秒发送消息
cancel(taskId)taskId: numbervoid
取消指定任务
clear()
-
void
清空队列中所有等待的任务
dumpInfo()
-
string
获取队列调试信息
onHandleMessage(message, taskId)message: Message
taskId: number
Promise<Any>
消息处理方法,子类可重写

属性

属性
类型
说明
queueNamestring
队列名称(只读)
lengthnumber
当前队列中的任务数量(只读)

3-2、Message 接口

interfaceMessage {
whatstring// 消息类型
dataAny// 消息数据
}

3-3、Task 接口

所有添加的任务,包括“Message 类型任务”和“Runnable 类型任务”,均会返回该类型实例,通过该实例可以“取消任务”、“获取任务结果”、“任务 Id”。

interfaceTask {
cancel(): void// 取消任务
getResult(): Promise<Any>       // 获取任务结果
getTaskId(): number// 获取任务 ID
}

3-4、异常类型

JSyncQueueCancelException

当任务被取消时,会抛出该类型的异常。

interfaceJSyncQueueCancelException {
messagestring
}

JSyncQueueException

当 JSyncQueue 内部发生异常时,会抛出该类型的异常。

值得注意:使用者编写的逻辑中抛出的异常会原封不动的抛到 Task.getResult().catch 中,而不是以 JSyncQueueException 类型抛出

interfaceJSyncQueueException {
messagestring
}

四、如何使用 JSyncQueue

4-1、使用 JSyncQueue 创建同步队列

如果你处理的场景均是简单的一次性任务,那么直接使用 JSyncQueue 创建一个同步队列,并压入 Runnable 闭包即可。

以下代码展示的逻辑细节:

  • • 代码中使用了 delay 函数模拟了两次耗时操作,并且返回结果
  • • 外部通过 Task 类型实例接收返回结果,并且打印
  • • 在第四次循环(即 i 为 3)的时候,会模拟抛出异常,异常内容会原封不动的抛到 catch 中

值得注意:

  • • 立即执行任务会严格按入队顺序执行
  • • 任务结果的接收处理(即对 Task.getResult() 的处理)和 JSyncQueue 对任务的处理是不保证顺序的,因为 Task.getResult() 的处理已不在队列范围内
immediatelyJSyncQueueJSyncQueue = newJSyncQueue("ImmediatelyJSyncQueue")
for (let i = 0; i < 5; ++i) {
const task = this.immediatelyJSyncQueue.post(async () => {
const delayTime1 = Math.round(Math.random() * 500)
Log.i(TAG`【添加5个Runnable】执行逻辑 i=${i} 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

if (i == 3) {
throw { message"模拟异常" } asError
    }

const delayTime2 = Math.round(Math.random() * 500)
Log.i(TAG`【添加5个Runnable】执行逻辑 i=${i} 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

return`jiangpengyong-添加5个Runnable ${i}`
  })
  task.getResult()
    .then((result) => {
Log.i(TAG`【添加5个Runnable-执行成功】i=${i} result=${result}`)
    })
    .catch((eError) => {
Log.e(TAG`【添加5个Runnable-执行异常】i=${i} e=${JSON.stringify(e)}`)
    })
    .finally(() => {
Log.i(TAG`【添加5个Runnable-执行结束】i=${i}`)
    })
}

// ========================================= 输出日志 =========================================
// 【添加5个Runnable】执行逻辑 i=0 第一段 将会模拟耗时=239
// 【添加5个Runnable】执行逻辑 i=0 第二段 将会模拟耗时=315
// 【添加5个Runnable】执行逻辑 i=1 第一段 将会模拟耗时=379
// 【添加5个Runnable-执行成功】i=0 result=jiangpengyong-添加5个Runnable 0
// 【添加5个Runnable-执行结束】i=0
// 【添加5个Runnable】执行逻辑 i=1 第二段 将会模拟耗时=391
// 【添加5个Runnable】执行逻辑 i=2 第一段 将会模拟耗时=499
// 【添加5个Runnable-执行成功】i=1 result=jiangpengyong-添加5个Runnable 1
// 【添加5个Runnable-执行结束】i=1
// 【添加5个Runnable】执行逻辑 i=2 第二段 将会模拟耗时=395
// 【添加5个Runnable】执行逻辑 i=3 第一段 将会模拟耗时=478
// 【添加5个Runnable-执行成功】i=2 result=jiangpengyong-添加5个Runnable 2
// 【添加5个Runnable-执行结束】i=2
// 【添加5个Runnable】执行逻辑 i=4 第一段 将会模拟耗时=166
// 【添加5个Runnable-执行异常】i=3 e={"message":"模拟异常"}
// 【添加5个Runnable-执行结束】i=3
// 【添加5个Runnable】执行逻辑 i=4 第二段 将会模拟耗时=33
// 【添加5个Runnable-执行成功】i=4 result=jiangpengyong-添加5个Runnable 4
// 【添加5个Runnable-执行结束】i=4

取消同步任务

通过返回的 Task 类型实例调用 cancel 方法可以进行取消任务。

下面的代码会取消第四次任务,所以在日志中会看到对应的取消异常,并且不会执行该任务。

lettaskTask | undefined
for (let i = 0; i < 5; ++i) {
const tempTask = this.immediatelyJSyncQueue.post(async () => {
const delayTime1 = Math.round(Math.random() * 500)
Log.i(TAG`【移除Runnable】执行逻辑 i=${i} 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

const delayTime2 = Math.round(Math.random() * 500)
Log.i(TAG`【移除Runnable】执行逻辑 i=${i} 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

if (i == 2) {
throw { message"模拟异常" } asError
    }
return`jiangpengyong-移除Runnable ${i}`
  })
  tempTask.getResult().then((result) => {
Log.i(TAG`【移除Runnable】执行成功 i=${i} result=${result}`)
  }).catch((eAny) => {
Log.e(TAG`【移除Runnable】执行异常 i=${i} e=${JSON.stringify(e)}`)
  }).finally(() => {
Log.i(TAG`【移除Runnable】执行完成 i=${i}`)
  })
if (i == 3) {
    task = tempTask
  }
}
Log.i(TAG`【移除Runnable】取消任务 task=${JSON.stringify(task)}`)
task?.cancel()

// ========================================= 输出日志 =========================================
// 【移除Runnable】执行逻辑 i=0 第一段 将会模拟耗时=263
// 【移除Runnable】取消任务 task={"taskId":13,"queue":{},"promise":{}}
// 【移除Runnable】执行异常 i=3 e={"message":"Cancel task by cancel function."}
// 【移除Runnable】执行完成 i=3
// 【移除Runnable】执行逻辑 i=0 第二段 将会模拟耗时=474
// 【移除Runnable】执行逻辑 i=1 第一段 将会模拟耗时=318
// 【移除Runnable】执行成功 i=0 result=jiangpengyong-移除Runnable 0
// 【移除Runnable】执行完成 i=0
// 【移除Runnable】执行逻辑 i=1 第二段 将会模拟耗时=6
// 【移除Runnable】执行逻辑 i=2 第一段 将会模拟耗时=406
// 【移除Runnable】执行成功 i=1 result=jiangpengyong-移除Runnable 1
// 【移除Runnable】执行完成 i=1
// 【移除Runnable】执行逻辑 i=2 第二段 将会模拟耗时=212
// 【移除Runnable】执行逻辑 i=4 第一段 将会模拟耗时=226
// 【移除Runnable】执行异常 i=2 e={"message":"模拟异常"}
// 【移除Runnable】执行完成 i=2
// 【移除Runnable】执行逻辑 i=4 第二段 将会模拟耗时=439
// 【移除Runnable】执行成功 i=4 result=jiangpengyong-移除Runnable 4
// 【移除Runnable】执行完成 i=4

延时执行 Runnable 类型任务

添加延时任务只需改用 postDelay 方法并传入延时参数

  • • 下面代码记录了添加任务到真正执行的延时,通过 realDelay 参数可以查看
  • • 使用了 delay 函数模拟了两次耗时操作,并模拟返回了处理结果
  • • 第四次任务抛出了异常,异常消息会原封不动的在 catch 的日志展示
  • • 因为延时任务的添加是按索引进行累加的,所以添加顺序其实并没变化,从最后的日志输出可以看到保证了执行顺序
for (let i = 0; i < 5; ++i) {
const startTime = systemDateTime.getTime(false)
const delayTime = i * 100
const task = this.delayJSyncQueue.postDelay(async () => {
const endTime = systemDateTime.getTime(false)
const realDelay = endTime - startTime
const delayTime1 = Math.round(Math.random() * 500)
Log.i(TAG`【添加5个Runnable】执行逻辑 delay=${delayTime} realDelay=${realDelay} i=${i} 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

const delayTime2 = Math.round(Math.random() * 500)
Log.i(TAG`【添加5个Runnable】执行逻辑 i=${i} 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

if (i == 3) {
throw { message"模拟异常" } asError
    }
return`jiangpengyong-添加5个Runnable ${i}`
  }, delayTime)
  task.getResult()
    .then((result) => {
Log.i(TAG`【添加5个Runnable】执行成功 i=${i} result=${result}`)
    })
    .catch((eError) => {
Log.e(TAG`【添加5个Runnable】执行异常 i=${i} e=${JSON.stringify(e)}`)
    })
    .finally(() => {
Log.i(TAG`【添加5个Runnable】执行结束 i=${i}`)
    })
}

// ========================================= 输出日志 =========================================
// 【添加5个Runnable】执行逻辑 delay=0 realDelay=1 i=0 第一段 将会模拟耗时=473
// 【添加5个Runnable】执行逻辑 i=0 第二段 将会模拟耗时=410
// 【添加5个Runnable】执行逻辑 delay=100 realDelay=888 i=1 第一段 将会模拟耗时=178
// 【添加5个Runnable】执行成功 i=0 result=jiangpengyong-添加5个Runnable 0
// 【添加5个Runnable】执行结束 i=0
// 【添加5个Runnable】执行逻辑 i=1 第二段 将会模拟耗时=204
// 【添加5个Runnable】执行逻辑 delay=200 realDelay=1272 i=2 第一段 将会模拟耗时=410
// 【添加5个Runnable】执行成功 i=1 result=jiangpengyong-添加5个Runnable 1
// 【添加5个Runnable】执行结束 i=1
// 【添加5个Runnable】执行逻辑 i=2 第二段 将会模拟耗时=36
// 【添加5个Runnable】执行逻辑 delay=300 realDelay=1721 i=3 第一段 将会模拟耗时=475
// 【添加5个Runnable】执行成功 i=2 result=jiangpengyong-添加5个Runnable 2
// 【添加5个Runnable】执行结束 i=2
// 【添加5个Runnable】执行逻辑 i=3 第二段 将会模拟耗时=483
// 【添加5个Runnable】执行逻辑 delay=400 realDelay=2686 i=4 第一段 将会模拟耗时=9
// 【添加5个Runnable】执行异常 i=3 e={"message":"模拟异常"}
// 【添加5个Runnable】执行结束 i=3
// 【添加5个Runnable】执行逻辑 i=4 第二段 将会模拟耗时=395
// 【添加5个Runnable】执行成功 i=4 result=jiangpengyong-添加5个Runnable 4
// 【添加5个Runnable】执行结束 i=4

取消延时任务

延时任务的取消操作和立即执行的取消操作是完全一样的,都是通过返回的 Task 实例调用 cancel 方法,这里就不再赘述。

4-2、继承 JSyncQueue 创建同步队列

如果你的同步逻辑需要集中管理或进行复用,可以考虑 Message 类型任务。

处理 Message 类型任务,需要继承 JSyncQueue 实现 onHandleMessage 方法,在该方法中会按入队顺序接收到 Message :

  • • 通过 Message.what 属性区分不同类别消息实现不同处理逻辑
  • • 通过 Message.data 属性可以获取外部传入的数据,数据类型是 Any 可以是任意类型数据,使用者自行转换为真实类型进行逻辑处理

具体操作如下:

  • • 定义一个 ImmediatelyQueue 类继承 JSyncQueue ,实现 onHandleMessage 方法
  • • 创建一个 ImmediatelyQueue 实例,并通过这个实例进行发送 Message 消息,同步队列会按入队顺序一个个进行分发给该实例的 onHandleMessage 方法进行处理
// 自定义 JSyncQueue
exportclassImmediatelyQueueextendsJSyncQueue {
private count = 0

asynconHandleMessage(messageMessage): Promise<Any> {
switch (message.what) {
case"say_hello": {
const name = message.data["name"]
this.count += 1

const delayTime1 = Math.round(Math.random() * 500)
Log.i("ImmediatelyQueue"`【say_hello】执行逻辑 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

const delayTime2 = Math.round(Math.random() * 500)
Log.i("ImmediatelyQueue"`【say_hello】执行逻辑 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

if (this.count % 10 == 5) {
throw { message"模拟异常" }
        }
return`你好,${name}。这是第${this.count}次打招呼。`
      }
// ... 其他 what 处理逻辑
    }
returnundefined
  }

privateasyncdelay(msnumber) {
returnnewPromise<Any>(resolve =>setTimeout(resolve, ms))
  }
}

// 使用逻辑
immediatelyQueueJSyncQueue = newImmediatelyQueue("ImmediatelyQueue")
for (let i = 0; i < 5; ++i) {
const tempTask = this.immediatelyQueue.sendMessage({
what`say_hello`,
data: { name'江澎涌'age20 + i },
  })
  tempTask.getResult()
    .then((result) => {
Log.i(TAG`【添加5个Message】执行成功 i=${i} result=${result}`)
    })
    .catch((eError) => {
Log.e(TAG`【添加5个Message】执行异常 i=${i} e=${JSON.stringify(e)}`)
    })
    .finally(() => {
Log.i(TAG`【添加5个Message】执行结束i=${i}`)
    })
}
// ========================================= 输出日志 =========================================
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":20}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=92
// 【say_hello】执行逻辑 第二段 将会模拟耗时=143
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":21}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=276
// 【say_hello】执行逻辑 第二段 将会模拟耗时=377
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":22}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=120
// 【say_hello】执行逻辑 第二段 将会模拟耗时=223
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":23}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=424
// 【say_hello】执行逻辑 第二段 将会模拟耗时=444
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":24}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=181
// 【say_hello】执行逻辑 第二段 将会模拟耗时=402

移除 Message 消息

使用 sendMessage 方法压入 “Message 类型任务” 同样会返回 Task 类型实例,调用该实例的 cancel 方法就可以取消该任务。

下列代码会取消第二个任务,所以不会看到 "age":11 的消息。

lettaskTask | undefined
for (let i = 0; i < 5; ++i) {
const tempTask = this.immediatelyQueue.sendMessage({
what`remove_message`,
data: { name'jiang peng yong'age10 + i },
  })
  tempTask.getResult().then((result) => {
Log.i(TAG`【移除Message】执行成功 i=${i} result=${result}`)
  }).catch((eAny) => {
Log.e(TAG`【移除Message】执行异常 i=${i} e=${JSON.stringify(e)}`)
  }).finally(() => {
Log.i(TAG`【移除Message】执行完成 i=${i}`)
  })
if (i == 1) {
    task = tempTask
  }
}
Log.i(TAG`【移除Message】取消任务 task=${JSON.stringify(task)}`)
task?.cancel()
// ========================================= 输出日志 =========================================
// onHandleMessage message={"what":"remove_message","data":{"name":"jiang peng yong","age":10}}
// 【remove_message】执行逻辑 第一段 将会模拟耗时=497
// 【remove_message】执行逻辑 第二段 将会模拟耗时=397
// onHandleMessage message={"what":"remove_message","data":{"name":"jiang peng yong","age":12}}
// 【remove_message】执行逻辑 第一段 将会模拟耗时=162
// 【remove_message】执行逻辑 第二段 将会模拟耗时=283
// onHandleMessage message={"what":"remove_message","data":{"name":"jiang peng yong","age":13}}
// 【remove_message】执行逻辑 第一段 将会模拟耗时=193
// 【remove_message】执行逻辑 第二段 将会模拟耗时=93
// onHandleMessage message={"what":"remove_message","data":{"name":"jiang peng yong","age":14}}
// 【remove_message】执行逻辑 第一段 将会模拟耗时=359
// 【remove_message】执行逻辑 第二段 将会模拟耗时=145

延时执行 Message 类型任务

  • • 定义一个 DelayQueue 类继承 JSyncQueue ,主要重写 onHandleMessage 方法,用于接收处理 Message
  • • 创建 DelayQueue 实例,通过这个实例调用 sendMessageDelay 方法即可达到相应的延时效果
exportclassDelayQueueextendsJSyncQueue {
private count = 0

asynconHandleMessage(messageMessage): Promise<Any> {
Log.i("DelayQueue"`onHandleMessage message=${JSON.stringify(message)}`)
switch (message.what) {
case"say_hello": {
const name = message.data["name"]
this.count += 1

const delayTime1 = Math.round(Math.random() * 500)
Log.i("DelayQueue"`【say_hello】执行逻辑 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

const delayTime2 = Math.round(Math.random() * 500)
Log.i("DelayQueue"`【say_hello】执行逻辑 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

if (this.count % 10 == 5) {
throw { message"模拟异常" }
        }
return`Hello,${name}. This is the ${this.count} th greeting.`
      }
    }
returnundefined
  }

privateasyncdelay(msnumber) {
returnnewPromise<Any>(resolve =>setTimeout(resolve, ms))
  }
}

delayQueueJSyncQueue = newDelayQueue("DelayQueue")
for (let i = 0; i < 5; ++i) {
const delayTime = i * 100
const task = this.delayQueue.sendMessageDelay({
what`say_hello`,
data: { name'江澎涌'age20 + i },
  }, delayTime)
  task.getResult()
    .then((result) => {
Log.i(TAG`【添加5个Message】执行成功 i=${i} result=${result}`)
    })
    .catch((eError) => {
Log.e(TAG`【添加5个Message】执行异常 i=${i} e=${JSON.stringify(e)}`)
    })
    .finally(() => {
Log.i(TAG`【添加5个Message】执行结束i=${i}`)
    })
}
// ========================================= 输出日志 ========================================= 
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":20}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=356
// 【say_hello】执行逻辑 第二段 将会模拟耗时=302
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":21}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=67
// 【say_hello】执行逻辑 第二段 将会模拟耗时=344
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":22}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=339
// 【say_hello】执行逻辑 第二段 将会模拟耗时=384
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":23}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=442
// 【say_hello】执行逻辑 第二段 将会模拟耗时=392
// onHandleMessage message={"what":"say_hello","data":{"name":"江澎涌","age":24}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=443
// 【say_hello】执行逻辑 第二段 将会模拟耗时=199

取消延时的 Message 类型任务

延时任务的取消操作和立即执行的取消操作是完全一样的,都是通过返回的 Task 实例调用 cancel 方法,这里就不再赘述。

同一队列压入 Message 类型任务和 Runnable 类型任务

对 JSyncQueue 同一实例压入 Message 和 Runnable 两种类型任务是支持的,会按照压入顺序进行执行和分发。

// ImmediatelyQueue 源码就不再展示,需要可以移步 Github 上查阅
immediatelyQueueJSyncQueue = newImmediatelyQueue("ImmediatelyQueue")
for (let i = 0; i < 10; ++i) {
if (i % 2 == 0) {
this.immediatelyQueue.post(async () => {
const delayTime1 = Math.round(Math.random() * 500)
Log.i(TAG`【添加10个Message和Runnable】执行逻辑 i=${i} 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

const delayTime2 = Math.round(Math.random() * 500)
Log.i(TAG`【添加10个Message和Runnable】执行逻辑 i=${i} 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

if (i / 2 == 3) {
throw { message"模拟异常" } asError
      }
return`小朋友-添加10个Message和Runnable ${i}`
    })
  } else {
this.immediatelyQueue.sendMessage({
what`say_hello`,
data: { name'小朋友'age: i },
    })
  }
}
// ========================================= 输出日志 ========================================= 
// 【添加10个Message和Runnable】执行逻辑 i=0 第一段 将会模拟耗时=416
// 【添加10个Message和Runnable】执行逻辑 i=0 第二段 将会模拟耗时=41
// onHandleMessage message={"what":"say_hello","data":{"name":"小朋友","age":1}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=184
// 【say_hello】执行逻辑 第二段 将会模拟耗时=63
// 【添加10个Message和Runnable】执行逻辑 i=2 第一段 将会模拟耗时=451
// 【添加10个Message和Runnable】执行逻辑 i=2 第二段 将会模拟耗时=223
// onHandleMessage message={"what":"say_hello","data":{"name":"小朋友","age":3}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=99
// 【say_hello】执行逻辑 第二段 将会模拟耗时=27
// 【添加10个Message和Runnable】执行逻辑 i=4 第一段 将会模拟耗时=273
// 【添加10个Message和Runnable】执行逻辑 i=4 第二段 将会模拟耗时=193
// onHandleMessage message={"what":"say_hello","data":{"name":"小朋友","age":5}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=20
// 【say_hello】执行逻辑 第二段 将会模拟耗时=231
// 【添加10个Message和Runnable】执行逻辑 i=6 第一段 将会模拟耗时=46
// 【添加10个Message和Runnable】执行逻辑 i=6 第二段 将会模拟耗时=198
// onHandleMessage message={"what":"say_hello","data":{"name":"小朋友","age":7}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=179
// 【say_hello】执行逻辑 第二段 将会模拟耗时=0
// 【添加10个Message和Runnable】执行逻辑 i=8 第一段 将会模拟耗时=131
// 【添加10个Message和Runnable】执行逻辑 i=8 第二段 将会模拟耗时=401
// onHandleMessage message={"what":"say_hello","data":{"name":"小朋友","age":9}}
// 【say_hello】执行逻辑 第一段 将会模拟耗时=452
// 【say_hello】执行逻辑 第二段 将会模拟耗时=40

4-3、取消队列中所有任务

对 JSyncQueue 实例调用 clear 方法,就会把队列中等待执行的任务,包括延时执行和立即执行的任务,全都取消。同时会抛出 JSyncQueueCancelException 类型异常。

for (let i = 0; i < 5; ++i) {
const task = this.immediatelyQueue.post(async () => {
const delayTime1 = Math.round(Math.random() * 500)
Log.i(TAG`【清空队列】执行逻辑 i=${i} 第一段 将会模拟耗时=${delayTime1}`)
awaitthis.delay(delayTime1)

const delayTime2 = Math.round(Math.random() * 500)
Log.i(TAG`【清空队列】执行逻辑 i=${i} 第二段 将会模拟耗时=${delayTime2}`)
awaitthis.delay(delayTime2)

return`小朋友-清空队列 ${i}`
  })
  task.getResult()
    .then((result) => {
Log.i(TAG`【清空队列】执行成功 i=${i} result=${result}`)
    })
    .catch((eError) => {
Log.e(TAG`【清空队列】执行异常 i=${i} e=${JSON.stringify(e)}`)
    })
    .finally(() => {
Log.i(TAG`【清空队列】执行结束 i=${i}`)
    })
}
this.immediatelyQueue.clear()
// ========================================= 输出日志 ========================================= 
// 【清空队列】执行逻辑 i=0 第一段 将会模拟耗时=14
// 【清空队列】执行异常 i=1 e={"message":"Cancel task by clear function."}
// 【清空队列】执行异常 i=2 e={"message":"Cancel task by clear function."}
// 【清空队列】执行异常 i=3 e={"message":"Cancel task by clear function."}
// 【清空队列】执行异常 i=4 e={"message":"Cancel task by clear function."}
// 【清空队列】执行结束 i=1
// 【清空队列】执行结束 i=2
// 【清空队列】执行结束 i=3
// 【清空队列】执行结束 i=4
// 【清空队列】执行逻辑 i=0 第二段 将会模拟耗时=125
// 【清空队列】执行成功 i=0 result=小朋友-清空队列 0
// 【清空队列】执行结束 i=0

五、作者博客

掘金:https://juejin.im/user/5c3033ef51882524ec3a88ba/posts

csdn:https://blog.csdn.net/weixin_37625173

公众号:微信搜索 "江澎涌"

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-05 05:55:17 HTTP/2.0 GET : https://c.mffb.com.cn/a/465861.html
  2. 运行时间 : 0.442925s [ 吞吐率:2.26req/s ] 内存消耗:4,398.31kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=3b1c69894e6775db23d3613468beeb4a
  1. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/runtime/temp/cefbf809ba1a84190cb04b0cb7abcf79.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/c.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000415s ] mysql:host=127.0.0.1;port=3306;dbname=c_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000691s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000945s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.003733s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000637s ]
  6. SELECT * FROM `set` [ RunTime:0.000265s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000593s ]
  8. SELECT * FROM `article` WHERE `id` = 465861 LIMIT 1 [ RunTime:0.025736s ]
  9. UPDATE `article` SET `lasttime` = 1770242117 WHERE `id` = 465861 [ RunTime:0.009653s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000318s ]
  11. SELECT * FROM `article` WHERE `id` < 465861 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002712s ]
  12. SELECT * FROM `article` WHERE `id` > 465861 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.011911s ]
  13. SELECT * FROM `article` WHERE `id` < 465861 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.064990s ]
  14. SELECT * FROM `article` WHERE `id` < 465861 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.107645s ]
  15. SELECT * FROM `article` WHERE `id` < 465861 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.100293s ]
0.444566s