Skip to content

Instantly share code, notes, and snippets.

@def-
Created March 11, 2015 13:29
Show Gist options
  • Save def-/f23b20bc2827f6cfbdc6 to your computer and use it in GitHub Desktop.
Save def-/f23b20bc2827f6cfbdc6 to your computer and use it in GitHub Desktop.
import threadpool
# Array needs explicit size to work, probably related to issue #2287
const a: array[0..5, int] = [1,2,3,4,5,6]
proc f(n) = echo "Hello ", n
proc main =
parallel:
for i in countup(0, a.high-1, 2):
spawn f(a[i])
spawn f(a[i+1])
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment