summary refs log tree commit diff stats
path: root/tests/stdlib/tuserlocks.nim
blob: 9251fa9e27626e729ba342a3b67ed581999b57dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
discard """
  matrix: "--threads:on"
"""

import std/rlocks

var r: RLock
r.initRLock()
doAssert r.tryAcquire()
doAssert r.tryAcquire()
r.release()
r.release()

block:
  var x = 12
  withRLock r:
    inc x
  doAssert x == 13

r.deinitRLock()