From: Axel S. <Axe...@en...> - 2008-04-08 15:11:32
|
Hi Tim, On Tue, 2008-04-08 at 15:12 +0100, Tim Docker wrote: > Hi, > > If I add code to the progressthreadedrts.hs demo to log the thread ids, > it's not what I expect. The posted action seems to run in a thread > different each time. In the output below, each "posted" output gets a > different thread id. Is this expected? Yes, since the thread id's you're getting are ghc's, not the OS's. It seems that there are no functions that give back the OS thread id. Internally, the postGUIAsync function will call Gtk's idle_add function in some random OS thread. The idle_add function then acquires the lock of the main loop and inserts the argument to postGUIAsync as a callback, releases the lock and returns. Once the Gtk OS thread is running again (or as soon as it is able to acquire the lock of Gtk's main loop) it will execute the argument containing your action within the right OS thread. At this point in time you print the thread id. The reason that it is different is as explained above. Axel. |