[6.10.0][Feat]新增排队超时机制

This commit is contained in:
chenfufeng
2025-02-11 16:32:10 +08:00
parent f3cb8c9046
commit ad448dae1f
3 changed files with 66 additions and 15 deletions

View File

@@ -3,11 +3,16 @@ package com.mogo.tts.base
data class MultiLangTtsEntity(
private var ttsList: List<LangTtsEntity>
) {
companion object {
private const val TIMEOUT_MILLIS = 60000
}
private val stringBuffer by lazy {
StringBuffer()
}
private var ttsIndex = 0
private var timeStamp: Long = 0
fun ttsNext(): LangTtsEntity? {
return if (ttsIndex in ttsList.indices) {
@@ -17,6 +22,14 @@ data class MultiLangTtsEntity(
}
}
fun markTime() {
timeStamp = System.currentTimeMillis()
}
fun isTimeout():Boolean {
return timeStamp > 0 && System.currentTimeMillis() - timeStamp >= TIMEOUT_MILLIS
}
override fun toString(): String {
return stringBuffer.let {
it.setLength(0)