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

This commit is contained in:
flywind 2021-04-17 17:48:22 +08:00 • committed by GitHub
commit 5c5f356347
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -1,8 +1,8 @@
discard """
cmd: "nim $target --threads:on $options $file"
matrix: "--threads:on"
"""
import rlocks
import std/rlocks
var r: RLock
r.initRLock()
@ -10,4 +10,11 @@ doAssert r.tryAcquire()
doAssert r.tryAcquire()
r.release()
r.release()
block:
var x = 12
withRLock r:
inc x
doAssert x == 13
r.deinitRLock()