Re[Haskell-cafe] [2]: Threading and FFI

Yves Parès limestrael at
Sat Feb 20 06:44:54 EST 2010

Dean Herington wrote:
>Careful.  If you're calling foreign functions 
>that rely on thread-local storage, you must call 
>them using the same OS thread (to provide them
>with the correct thread state), which means using 
>the same, *bound*, Haskell thread.  It wouldn't 
>work to call them from both the main Haskell 
>thread and another Haskell thread, even if the 
>latter were a bound thread, as there would be two 
>copies of thread-local storage at play.

That's alright. I'm used to putting all the related calls in the same thread
as long as it is possible. It'd seem unlogical to me -- conceptually
speaking -- to spread OpenGL calls between several threads.

I understand better, now. Actually, I think I was getting worked up for
nothing ^^.
Just one last remark: when I moved all my OpenGL calls from the main thread
to an unbound thread. I thought it'd not work -- because I assumed I would
have to launch it in a bound thread -- and however it went right...

Yves Parès

Live long and prosper
View this message in context:
Sent from the Haskell - Haskell-Cafe mailing list archive at

More information about the Haskell-Cafe mailing list