I've sketched out a Haskell interface to a C++ toolkit that uses threads.
It's the Haiku (BeOS) platform API (BeOS is an obscure OS from the '90s,
Haiku is a pretty faithful recent open source re-implementation.)

The API is fairly obvious and I imagine much like others that support
windowed graphic interfaces.  You have your Window class that spawns
a thread, and various virtual methods of that class support program
interface with the events involving that window.

The curious thing is that I can get this to work with my example program
only if it is NOT linked with -threaded.

If linked with -threaded, when the application comes up I have 4 threads:
the main thread and window thread, and two threads apparently created by
the Haskell runtime.  Shortly (but not immediately) after the first callback
from the window thread, the window thread quietly dies.  Callbacks from
the main thread work fine.

Linked without -threaded, I have only the 2 natural threads, and the
window thread can call back apparently without problems.

I imagine I'm at fault somewhere in this, since I am also responsible
for the GHC port to Haiku, but just wondering if this suggests an
obvious course of inquiry to anyone.  I assume it's not working as
intended, as from the documentation I would rather have guessed that
-thread would be required in this situation.

thanks!

        Donn Cave, d...@avvanta.com

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to