[Haskell-cafe] Re: Threads with high CPU usage

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Mon Dec 22 16:36:35 EST 2008


On Mon, 2008-12-22 at 22:12 +0100, Günther Schmidt wrote:
> Hi guys,
> 
> I just tried to forkIO-off the database code to keep the UI responsive  
> using Takusen with Sqlite this time.
> 
> The problem persists though, the UI freezes.

You might need to provide us more details on the GUI code. As I
understand if you're using gtk2hs. You need to make sure that you're not
blocking the GUI event loop by making blocking calls in event handlers.
All blocking stuff has to be run via forkIO and the event handler must
be allowed to return so that Gtk+ can redraw windows etc.

In this context, by "blocking" I mean blocking a single Haskell thread,
which is of course different from the safe/unsafe foreign calls which
blocks a whole OS thread and thus all the Haskell threads.

Duncan



More information about the Haskell-Cafe mailing list