Skip to content

Instantly share code, notes, and snippets.

@shybovycha
Forked from def-/parallel.nim
Created March 26, 2017 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shybovycha/83004a4844924acee486fece73467b6a to your computer and use it in GitHub Desktop.
Save shybovycha/83004a4844924acee486fece73467b6a 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