Hi Andy, On 31.01.2010, at 18:26, Andy Stewart wrote:
> Hi Axel, > > unsafeInitGUIForThreadedRTS there is still a necessary? Even you have > fix this problem? > > If unsafeInitGUIForThreadedRTS is not necessary, we should remove > `unsafeInitGUIForThreadedRTS` and allowed use `-threaded` flag with > `initGUI` directly. > > Current, if i use `initGUI` with `-threaded` flag, will got error: > > ------------------------------> error start > <------------------------------ > initGUI: Gtk+ is single threaded and so cannot safely be used from > multiple Haskell threads when using GHC's threaded RTS. You can > avoid this error by relinking your program without using the > '-threaded' flag. If you have to use the threaded RTS and are > absolutely sure that you only ever call Gtk+ from a single OS > thread then you can use the function: unsafeInitGUIForThreadedRTS > ------------------------------> error end > <------------------------------ > > What do you think? Actually, the semantics of multi-threading in Gtk2Hs has not changed. It is still necessary to call all Gtk functions from a single Haskell thread and to use the post* functions in Graphics.UI.Gtk.General.General to emit a function call from a different thread. This is unlikely to change in the future since it is impossible on Windows to call the Win32 API from more than one thread. It is possible on Unix to call X11 from different threads (although not at the same time), but it is probably pointless to allow this if those programs cannot be run on Windows afterwards. I agree that this warning is a bit harsh, or that 'unsafeInitGUIForThreadedRTS' is a bit of a mouthful. It's quite alright to use Gtk2Hs in a multithreaded program as long as you call all GUI functions from the same thread. You may call Glib, Cairo and e.g. Pango functions from a different thread (but you may not access the same data structure concurrently from different Haskell threads). So you can implement your redraw handler in a different thread and post the result to the main thread that displays the result using Gtk functions. We probably need some sort of user guide that explains all these issues. Thanks for raising this point, Axel. > Cheers, > > -- Andy > > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the > business > Choose flexible plans and management services without long-term > contracts > Personal 24x7 support from experience hosting pros just a phone call > away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > Gtk2hs-devel mailing list > Gtk2hs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel