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

import std/rlocks
import std/assertions

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()