[6.10.0][Feat]新增排队超时机制
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user