summary refs log tree commit diff stats
path: root/tests/parallel/tsysspawn.nim
blob: 7244a5ee663a66565353b0255bac6fb261c0dc86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
discard """
  output: '''4
8'''
  cmd: "nim $target --threads:on $options $file"
"""

import threadpool

var
  x, y = 0

proc p1 =
  for i in 0 .. 10_000:
    discard

  atomicInc x

proc p2 =
  for i in 0 .. 10_000:
    discard

  atomicInc y, 2

for i in 0.. 3:
  spawn(p1())
  spawn(p2())

sync()

echo x
echo y