[Haskell-cafe] How to ensure code executes in the context of a specific OS thread?
Felipe Almeida Lessa
felipe.lessa at gmail.com
Mon Jul 4 07:22:33 CEST 2011
On Mon, Jul 4, 2011 at 2:02 AM, Jason Dagit <dagitj at gmail.com> 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.
Cheers! =)
[1] http://hackage.haskell.org/packages/archive/gtk/0.12.0/doc/html/Graphics-UI-Gtk-General-General.html#v:postGUISync
[2] http://developer.gnome.org/glib/2.28/glib-The-Main-Event-Loop.html#g-idle-add
[3] http://hackage.haskell.org/packages/archive/gtk/0.12.0/doc/html/src/Graphics-UI-Gtk-General-General.html#postGUISync
[4] (link seems broken)
http://www.go-mono.com/docs/monodoc.ashx?link=M%3aGtk.Application.Invoke(System.EventHandler)
[5] http://developer.gnome.org/glib/2.28/glib-The-Main-Event-Loop.html#g-timeout-add
[6] https://github.com/mono/gtk-sharp/blob/master/gtk/Application.cs#L200
--
Felipe.
More information about the Haskell-Cafe
mailing list