summary refs log tree commit diff stats
path: root/doc/backends.txt
diff options
context:
space:
mode:
authorGrzegorz Adam Hankiewicz <gradha@imap.cc>2014-06-22 20:19:09 +0200
committerGrzegorz Adam Hankiewicz <gradha@imap.cc>2014-06-22 20:20:14 +0200
commit6ca24cd246a38bf353219f38e1725baf982c9f6e (patch)
treeee2e79f69a693ce8930a474eaf89d06902fd1729 /doc/backends.txt
parentff1fe8b4ec64264171b419faff5fba4cf88b9a78 (diff)
downloadNim-6ca24cd246a38bf353219f38e1725baf982c9f6e.tar.gz
Adds tidbit about threads.
Diffstat (limited to 'doc/backends.txt')
-rw-r--r--doc/backends.txt22
1 files changed, 21 insertions, 1 deletions
diff --git a/doc/backends.txt b/doc/backends.txt
index 66d702f4e..8e16502e7 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -387,4 +387,24 @@ these for the Nimrod side should be enough.
 
 
 Thread coordination
-===================
+-------------------
+
+When the ``NimMain()`` function is called Nimrod initializes the garbage
+collector to the current thread, which is usually the main thread of your
+application. If your C code later spawns a different thread and calls Nimrod
+code, the garbage collector will fail to work properly and you will crash.
+
+As long as you don't use the threadvar emulation Nimrod uses native thread
+variables, of which you get a fresh version whenever you create a thread. You
+can then attach a GC to this thread via
+
+.. code-block:: nimrod
+
+  setStackBottom(addr(someLocal))
+  initGC()
+
+At the moment this support is still experimental so you need to expose these
+functions yourself or submit patches to request a public API. If the Nimrod
+code you are calling is short lived, another possible solution is to disable
+the garbage collector and enable it after the call from your background
+thread.