[Haskell-cafe] Re: native threads vs. -threaded

Donn Cave donn at avvanta.com
Sun Feb 28 11:47:53 EST 2010

Quoth Achim Schneider <barsoap at web.de>,
> Donn Cave <donn at avvanta.com> wrote:
>> 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.
> Could it be that Haiku is expecting BeOS threads but you give it UNIX
> processes? It might be that all threads serving a GUI app must be part
> of the same team.

No, I'm not creating any other threads or processes, other than the
window thread that's implicitly created by the window API.  If it
helps, a coarse outline of the API:

   class W : public BWindow {
	W(...params...): BWindow(...params...) {
		... initialize graphic elements
	void MessageReceived(BMessage *msg) {
		... respond to event by calling Haskell function
		// will lead to thread abort if linked -threaded.

main thread:
   W *w = W(...params...);
   w->Show();   // thread spawned by this member function.

I haven't written any code to support the above - BWindow::Show()
was provided by the platform.  I did of course have to do a lot
of hacking around with FFI stuff.  The BWindow-derived object
stores a table of foreign wrapper pointers to callback functions
that take a StablePtr, etc., and I wouldn't know where to start
thinking about that works with garbage collection.

	Donn Cave, donn at avvanta.com

More information about the Haskell-Cafe mailing list