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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
discard """
output: '''4
8
(a: 1)
2
2
'''
matrix: "--mm:refc"
"""
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
#--------------------------------------------------------
# issue #14014
import threadpool
type A = object
a: int
proc f(t: typedesc): t =
t(a:1)
let r = spawn f(A)
echo ^r
proc f2(x: static[int]): int =
x
let r2 = spawn f2(2)
echo ^r2
type statint = static[int]
proc f3(x: statint): int =
x
let r3 = spawn f3(2)
echo ^r3
|