From: Wolfgang T. <wol...@gm...> - 2005-07-21 02:36:36
|
Christian Hofer wrote: > By the way, is there a way to get MVar concurrency working together > with HOC? Can I use MVars just like that (after telling Cocoa to > run thread-safe)? Do I have to use POSIX threads? Compile your program using the -threaded option to ghc in order to enable the threaded run time system. Then, "forkIO" spawns an "unbound" (lightweight) thread. The RTS may run multiple lightweight threads in a single POSIX thread. Do not call Cocoa from threads created by forkIO. "forkOS" spawns a POSIX thread. Best of all, you can also use NSThread from HOC. And YES, MVars will work between all those different threads. Note that if you don't use -threaded, calls to forkIO will cause a run time error and calls to any Haskell code from other OS threads (NSThreads, pthreads, whatever) will most likely result in a crash. Cheers, Wolfgang |