Concurrent Haskell (GHC) and Win32 Applications ?
Antony Blakey
antony.blakey@ihug.com.au
Sat, 09 Mar 2002 23:44:22 +1030
Hi,
I'm experimenting with GHC as a platform for writing a Win32 GUI
application, and I've hit what I think is a brick wall.
The problem I think is with the lightweight thread implementation -
Win32 calls can (and will) block the OS thread that makes the call,
which blocks the entire system. Given that I'm wanting to write a
network server with a Win32 GUI, this is obviously a Bad Thing.
So, does any know if I missing some vital piece of information? I am
using the following reduced test case, which I don't think is clueless.
import Win32
import Concurrent
endless:: Char -> IO ()
endless c = do { putChar c; endless c }
main = do { task1; task2; endless 'b' }
where
task1 = forkIO ( do { messageBox nullHANDLE "Hey" "Yeah" mB_OK;
return () } )
task2 = forkIO ( endless 'a' )
It does intersperse the 'a' and 'b' output nicely, but stops while the
message box is on the screen.
I'm not keen on writing a seperate GUI management thread in C++ and
linking - the point is to do all of this in Haskell and write an
application indistinguishable from a C++ GUI app e.g. imagine Simon
Peyton Jones' sample webserver with a realtime GUI monitor.
Thanks in advance for any pointers!