summaryrefslogtreecommitdiff
path: root/docs/users_guide/ffi-chap.xml
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-02-27 14:07:29 +0000
committerSimon Marlow <marlowsd@gmail.com>2014-02-27 14:07:34 +0000
commitaf6746fb6b5adb5ba5be6e0f647c4ebe767ce084 (patch)
treefce2e5cf3989597d3a1446f68c18d82bb9d1403f /docs/users_guide/ffi-chap.xml
parent68c0d8689dd93cb0ce74a288e82f2ed997c31acc (diff)
downloadhaskell-af6746fb6b5adb5ba5be6e0f647c4ebe767ce084.tar.gz
Add hs_thread_done() (#8124)
See documentation for details.
Diffstat (limited to 'docs/users_guide/ffi-chap.xml')
-rw-r--r--docs/users_guide/ffi-chap.xml34
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/users_guide/ffi-chap.xml b/docs/users_guide/ffi-chap.xml
index 4d91947c72..e7d5a0c37d 100644
--- a/docs/users_guide/ffi-chap.xml
+++ b/docs/users_guide/ffi-chap.xml
@@ -213,6 +213,40 @@ newtype {-# CTYPE "useconds_t" #-} T = ...
</programlisting>
</para>
</sect2>
+
+ <sect2>
+ <title><literal>hs_thread_done()</literal></title>
+
+<programlisting>
+void hs_thread_done(void);
+</programlisting>
+
+ <para>
+ GHC allocates a small amount of thread-local memory when a
+ thread calls a Haskell function via a <literal>foreign
+ export</literal>. This memory is not normally freed until
+ <literal>hs_exit()</literal>; the memory is cached so that
+ subsequent calls into Haskell are fast. However, if your
+ application is long-running and repeatedly creates new
+ threads that call into Haskell, you probably want to arrange
+ that this memory is freed in those threads that have
+ finished calling Haskell functions. To do this, call
+ <literal>hs_thread_done()</literal> from the thread whose
+ memory you want to free.
+ </para>
+
+ <para>
+ Calling <literal>hs_thread_done()</literal> is entirely
+ optional. You can call it as often or as little as you
+ like. It is safe to call it from a thread that has never
+ called any Haskell functions, or one that never will. If
+ you forget to call it, the worst that can happen is that
+ some memory remains allocated until
+ <literal>hs_exit()</literal> is called. If you call it too
+ often, the worst that can happen is that the next call to a
+ Haskell function incurs some extra overhead.
+ </para>
+ </sect2>
</sect1>
<sect1 id="ffi-ghc">