parent
6a355a4db0
commit
c86fdfa1ee
1 changed files with 28 additions and 0 deletions
28
tests/notnil/tnotnil5.nim
Normal file
28
tests/notnil/tnotnil5.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
discard """
|
||||||
|
matrix: "--threads:on"
|
||||||
|
"""
|
||||||
|
|
||||||
|
{.experimental: "parallel".}
|
||||||
|
{.experimental: "notnil".}
|
||||||
|
import threadpool
|
||||||
|
|
||||||
|
type
|
||||||
|
AO = object
|
||||||
|
x: int
|
||||||
|
|
||||||
|
A = ref AO not nil
|
||||||
|
|
||||||
|
proc process(a: A): A =
|
||||||
|
return A(x: a.x+1)
|
||||||
|
|
||||||
|
proc processMany(ayys: openArray[A]): seq[A] =
|
||||||
|
var newAs: seq[FlowVar[A]]
|
||||||
|
|
||||||
|
parallel:
|
||||||
|
for a in ayys:
|
||||||
|
newAs.add(spawn process(a))
|
||||||
|
for newAflow in newAs:
|
||||||
|
let newA = ^newAflow
|
||||||
|
if isNil(newA):
|
||||||
|
return @[]
|
||||||
|
result.add(newA)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue