tsysspawn.nim 643 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. discard """
  2. output: '''4
  3. 8
  4. (a: 1)
  5. 2
  6. 2
  7. '''
  8. matrix: "--mm:refc"
  9. """
  10. import threadpool
  11. var
  12. x, y = 0
  13. proc p1 =
  14. for i in 0 .. 10_000:
  15. discard
  16. atomicInc x
  17. proc p2 =
  18. for i in 0 .. 10_000:
  19. discard
  20. atomicInc y, 2
  21. for i in 0.. 3:
  22. spawn(p1())
  23. spawn(p2())
  24. sync()
  25. echo x
  26. echo y
  27. #--------------------------------------------------------
  28. # issue #14014
  29. import threadpool
  30. type A = object
  31. a: int
  32. proc f(t: typedesc): t =
  33. t(a:1)
  34. let r = spawn f(A)
  35. echo ^r
  36. proc f2(x: static[int]): int =
  37. x
  38. let r2 = spawn f2(2)
  39. echo ^r2
  40. type statint = static[int]
  41. proc f3(x: statint): int =
  42. x
  43. let r3 = spawn f3(2)
  44. echo ^r3