diff options
author | flywind <xzsflywind@gmail.com> | 2021-03-28 15:57:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 00:57:22 -0700 |
commit | c86fdfa1ee2cbba201b0a6182212ced5e218dc65 (patch) | |
tree | 518a31fe0dcdbdd727eeb9a0dd75651968bc6a93 | |
parent | 6a355a4db05addb01fc02df0243c540f100bf107 (diff) | |
download | Nim-c86fdfa1ee2cbba201b0a6182212ced5e218dc65.tar.gz |
add testcase for #9466 (#17538)
-rw-r--r-- | tests/notnil/tnotnil5.nim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/notnil/tnotnil5.nim b/tests/notnil/tnotnil5.nim new file mode 100644 index 000000000..2dcb7f7c3 --- /dev/null +++ b/tests/notnil/tnotnil5.nim @@ -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) |