summary refs log tree commit diff stats
path: root/tests/parallel
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-11-10 01:33:25 +0100
committerAraq <rumpf_a@web.de>2014-11-10 01:33:25 +0100
commitb6e006fbbe0db7c786e4fb4a3039d544991e380c (patch)
treea1ed29727d3baeb03da87678a88631ed76e52b1c /tests/parallel
parent830e0c0009d25d84a26fc997722eee4ecd015fd9 (diff)
downloadNim-b6e006fbbe0db7c786e4fb4a3039d544991e380c.tar.gz
fixes #1646
Diffstat (limited to 'tests/parallel')
-rw-r--r--tests/parallel/t5000.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/parallel/t5000.nim b/tests/parallel/t5000.nim
new file mode 100644
index 000000000..025c327fa
--- /dev/null
+++ b/tests/parallel/t5000.nim
@@ -0,0 +1,22 @@
+discard """
+  output: '''50005000'''
+"""
+
+import threadpool, strutils
+
+proc foo(x: int): string = $x
+
+proc main() =
+  var a = newSeq[int]()
+  for i in 1..10000:
+    add(a, i)
+
+  var s = 0
+  for i in a:
+    s += parseInt(^spawn(foo(i)))
+  echo s
+
+setMaxPoolSize 2
+
+parallel:
+  spawn main()