replace defer with try ... finally (#17753)

This commit is contained in:
flywind
2021-04-17 17:48:22 +08:00
committed by GitHub
parent 7e94420847
commit 5c5f356347
2 changed files with 14 additions and 7 deletions

View File

@@ -47,9 +47,9 @@ proc release*(lock: var RLock) =
template withRLock*(lock: var RLock, code: untyped): untyped =
## Acquires the given lock and then executes the code.
block:
acquire(lock)
defer:
release(lock)
{.locks: [lock].}:
acquire(lock)
{.locks: [lock].}:
try:
code
finally:
release(lock)