summary refs log tree commit diff stats
path: root/tests/threads/tonthreadcreation.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/threads/tonthreadcreation.nim')
-rw-r--r--tests/threads/tonthreadcreation.nim26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/threads/tonthreadcreation.nim b/tests/threads/tonthreadcreation.nim
new file mode 100644
index 000000000..61529477d
--- /dev/null
+++ b/tests/threads/tonthreadcreation.nim
@@ -0,0 +1,26 @@
+discard """
+  disabled: i386
+  matrix: "--mm:refc; --mm:orc --deepcopy:on"
+  output: '''some string here
+dying some string here'''
+"""
+
+var
+  someGlobal: string = "some string here"
+  perThread {.threadvar.}: string
+
+proc threadDied() {.gcsafe.} =
+  echo "dying ", perThread
+
+proc foo() {.thread.} =
+  onThreadDestruction threadDied
+  {.gcsafe.}:
+    deepCopy(perThread, someGlobal)
+  echo perThread
+
+proc main =
+  var t: Thread[void]
+  createThread[void](t, foo)
+  t.joinThread()
+
+main()