[Haskell-cafe] Re: FFI and callbacks

Bulat Ziganshin bulatz at HotPOP.com
Thu Jul 21 03:07:15 EDT 2005


Hello Simon,

Thursday, July 21, 2005, 1:16:10 AM, you wrote:

>> However, if one of my Haskell-based callbacks creates new threads with
>> forkIO, I could be in trouble; if they make any calls into C, a new
>> bound OS thread would be created for them, and this could wind up
>> causing trouble in C.  I would probably need some sort of "global
>> MVar" to synchronize access into the C world.

SM> Bingo.  This is why you need to make all your calls to the C library
SM> from a single thread.

you can either:
1) made all calls from single thread
2) put all calls in "withMVar lock", where `lock` is a global MVar

JG> 1. It seems that there is no function that says "block the current
JG> thread until the thread given by ThreadId dies"

GHC concurrency stuff is very basic and low-level. there is several
libs which adds some more high-level abilities, including MissingH (see
Child.hs) and some functions in http://www-i2.informatik.rwth-aachen.de/~stolz/Haskell/CA.hs


-- 
Best regards,
 Bulat                            mailto:bulatz at HotPOP.com





More information about the Haskell-Cafe mailing list