summary refs log tree commit diff stats
path: root/tests/parallel
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-05-23 08:57:16 +0200
committerAraq <rumpf_a@web.de>2014-05-23 08:57:16 +0200
commitd2dbcf2fa44aa76c6c7ed2c07641560640e6bc6b (patch)
tree86ce8b05f9f73fa637f1c43cbd68aed6a4087a24 /tests/parallel
parent417b9f5a1d13f26842b1337395a0f5b57827cc12 (diff)
downloadNim-d2dbcf2fa44aa76c6c7ed2c07641560640e6bc6b.tar.gz
progress with futures
Diffstat (limited to 'tests/parallel')
-rw-r--r--tests/parallel/tflowvar.nim17
-rw-r--r--tests/parallel/tsysspawn.nim31
-rw-r--r--tests/parallel/tsysspawnbadarg.nim9
3 files changed, 57 insertions, 0 deletions
diff --git a/tests/parallel/tflowvar.nim b/tests/parallel/tflowvar.nim
new file mode 100644
index 000000000..77fab14b5
--- /dev/null
+++ b/tests/parallel/tflowvar.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''foobarfoobarbazbearbazbear'''
+  cmd: "nimrod $target --threads:on $options $file"
+"""
+
+import threadpool
+
+proc computeSomething(a, b: string): string = a & b & a & b
+
+proc main =
+  let fvA = spawn computeSomething("foo", "bar")
+  let fvB = spawn computeSomething("baz", "bear")
+
+  echo(^fvA, ^fvB)
+
+main()
+sync()
diff --git a/tests/parallel/tsysspawn.nim b/tests/parallel/tsysspawn.nim
new file mode 100644
index 000000000..fc7921b0e
--- /dev/null
+++ b/tests/parallel/tsysspawn.nim
@@ -0,0 +1,31 @@
+discard """
+  output: '''4
+8'''
+  cmd: "nimrod $target --threads:on $options $file"
+"""
+
+import threadpool
+
+var
+  x, y = 0
+
+proc p1 =
+  for i in 0 .. 10_000:
+    discard
+
+  atomicInc x
+
+proc p2 =
+  for i in 0 .. 10_000:
+    discard
+
+  atomicInc y, 2
+
+for i in 0.. 3:
+  spawn(p1())
+  spawn(p2())
+
+sync()
+
+echo x
+echo y
diff --git a/tests/parallel/tsysspawnbadarg.nim b/tests/parallel/tsysspawnbadarg.nim
new file mode 100644
index 000000000..120975ed5
--- /dev/null
+++ b/tests/parallel/tsysspawnbadarg.nim
@@ -0,0 +1,9 @@
+discard """
+  line: 7
+  errormsg: "'spawn' takes a call expression"
+  cmd: "nimrod $target --threads:on $options $file"
+"""
+
+import threadpool
+
+spawn(1)