concurrent 异常处理
This commit is contained in:
parent
0b91a47f05
commit
e5c70e3d25
|
|
@ -246,14 +246,19 @@ abstract class BaseRecordHelper<T: BaseRecord> {
|
||||||
|
|
||||||
|
|
||||||
fun getRecordList(): List<T> {
|
fun getRecordList(): List<T> {
|
||||||
|
try {
|
||||||
|
mRecordLocker.lock()
|
||||||
return mRecordList.toList()
|
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()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue