Skip to content

Commit

Permalink
Always Release storeLock
Browse files Browse the repository at this point in the history
Signed-off-by: Amr Yousef <amr.farid140@gmail.com>
  • Loading branch information
amrfarid140 committed Oct 1, 2024
1 parent 24ed3cf commit 8510cc1
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 8510cc1

Please sign in to comment.