Skip to content

Commit

Permalink
Always Release storeLock
Browse files Browse the repository at this point in the history
  • Loading branch information
amrfarid140 committed Oct 1, 2024
1 parent f2ed2f2 commit 51605da
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
block: suspend ThreadSafety.() -> Output,
): Output {
storeLock.lock()
val threadSafety = requireNotNull(keyToThreadSafety[key])
val output = threadSafety.block()
storeLock.unlock()
return output
try {
val threadSafety = requireNotNull(keyToThreadSafety[key])
val output = threadSafety.block()
return output
} finally {
storeLock.unlock()
}
}

private suspend fun conflictsMightExist(key: Key): Boolean {
Expand Down

0 comments on commit 51605da

Please sign in to comment.