concurrent 异常处理

This commit is contained in:
renhaoting 2026-01-19 14:41:57 +08:00
parent 0b91a47f05
commit e5c70e3d25
1 changed files with 7 additions and 2 deletions

View File

@ -246,14 +246,19 @@ abstract class BaseRecordHelper<T: BaseRecord> {
fun getRecordList(): List<T> { fun getRecordList(): List<T> {
return mRecordList.toList() try {
mRecordLocker.lock()
return mRecordList.toList()
} finally {
mRecordLocker.unlock()
}
} }
protected fun saveRecordList2Sp() { protected fun saveRecordList2Sp() {
mbgScope.launch { mbgScope.launch {
try { try {
mRecordLocker.lock() mRecordLocker.lock()
SpUtil.instance().putList(mSpKey, mRecordList) SpUtil.instance().putList(mSpKey, getRecordList())
} finally { } finally {
mRecordLocker.unlock() mRecordLocker.unlock()
} }