tdisjoint_slice2.nim 406 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. output: '''0
  3. 1
  4. 2
  5. 3
  6. 4
  7. 5
  8. 6
  9. 7
  10. 8'''
  11. sortoutput: true
  12. """
  13. import threadpool
  14. proc f(a: openArray[int]) =
  15. for x in a: echo x
  16. proc f(a: int) = echo a
  17. proc main() =
  18. var a: array[0..9, int] = [0,1,2,3,4,5,6,7,8,9]
  19. parallel:
  20. spawn f(a[0..2])
  21. #spawn f(a[16..30])
  22. var i = 3
  23. while i <= 8:
  24. spawn f(a[i])
  25. spawn f(a[i+1])
  26. inc i, 2
  27. # is correct here
  28. main()