
On Sun, Jul 3, 2011 at 10:22 PM, Felipe Almeida Lessa
On Mon, Jul 4, 2011 at 2:02 AM, Jason Dagit
wrote: My second question is, if there is no current workaround then how can we remedy this situation? It seems like there could be an api function like: runOnOriginalThread :: IO a -> IO a
Isn't there something on Cocoa that would allow you to implement this function? For example, to implement postGUISync [1] on Gtk2Hs, Glib's g_idle_add() [2] is used [3]. To implement Gtk.Application.Invoke [4] on Gtk#, Glib's g_timeout_add with a timeout of 0 seconds is used [6]. In other words, some way of running an arbitrary function inside Cocoa's event loop.
There are a few objective-c specific ways of sending something to the right thread. I was hoping to find something a bit more general and easier to call from Haskell (I believe the way the FFI works I'll have to make a new wrapper for each "thing" because I can't directly call objective-c). I suppose I should try adding wrappers around all the GLFW functions so that it sends the request over to the main thread and see if it solves my problem. The downside is that it would be a lot of wrapper code and it would be nice to have solution that other libraries can use. Thanks for the idea. Jason