'parallel' statement almost working
This commit is contained in:
parent
31b8fd66b1
commit
417b9f5a1d
10 changed files with 470 additions and 115 deletions
|
|
@ -1,20 +1,20 @@
|
|||
discard """
|
||||
outputsub: "EVEN 28"
|
||||
"""
|
||||
|
||||
import threadpool
|
||||
|
||||
proc f(a: openArray[int]) =
|
||||
for x in a: echo x
|
||||
|
||||
proc f(a: int) = echo a
|
||||
proc odd(a: int) = echo "ODD ", a
|
||||
proc even(a: int) = echo "EVEN ", a
|
||||
|
||||
proc main() =
|
||||
var a: array[0..30, int]
|
||||
for i in low(a)..high(a): a[i] = i
|
||||
parallel:
|
||||
#spawn f(a[0..15])
|
||||
#spawn f(a[16..30])
|
||||
var i = 0
|
||||
while i <= 29:
|
||||
spawn f(a[i])
|
||||
spawn f(a[i+1])
|
||||
spawn even(a[i])
|
||||
spawn odd(a[i+1])
|
||||
inc i, 2
|
||||
# is correct here
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
discard """
|
||||
errormsg: "cannot prove: i + 1 <= 30"
|
||||
errormsg: "can prove: i + 1 > 30"
|
||||
line: 21
|
||||
"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue