* ref #14873

* comment

* Update lib/core/locks.nim
This commit is contained in:
flywind 2021-04-06 22:21:58 +08:00 • committed by GitHub
commit c7b4639460
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View file

@ -28,6 +28,11 @@ type
{.push stackTrace: off.} {.push stackTrace: off.}
proc `$`*(lock: Lock): string =
# workaround bug #14873
result = "()"
proc initLock*(lock: var Lock) {.inline.} = proc initLock*(lock: var Lock) {.inline.} =
## Initializes the given lock. ## Initializes the given lock.
when not defined(js): when not defined(js):

View file

@ -1,10 +1,10 @@
discard """ discard """
output: '''3''' targets: "c cpp js"
cmd: "nim $target --threads:on $options $file" matrix: "--threads:on"
""" """
#bug #6049 #bug #6049
import uselocks import uselocks
var m = createMyType[int]() var m = createMyType[int]()
echo $m.use() doAssert m.use() == 3

View file

@ -9,3 +9,7 @@ proc createMyType*[T]: MyType[T] =
proc use* (m: var MyType): int = proc use* (m: var MyType): int =
withLock m.lock: withLock m.lock:
result = 3 result = 3
block:
var l: Lock
doAssert $l == "()"