STM help

Donald Bruce Stewart dons at cse.unsw.edu.au
Mon Jul 4 04:40:56 EDT 2005


john:
> On Mon, Jul 04, 2005 at 12:06:11PM +0400, Bulat Ziganshin wrote:
> > Hello John,
> > 
> > Sunday, July 03, 2005, 11:16:30 PM, you wrote:
> > 
> > JM> have a screen update thread, this is the only one that will make curses
> > JM> calls. 
> > JM> everything else communicates with the screen by modifying TVars holding
> > JM> data values like so
> > 
> > in my own program i plan to use different approach. may it will be
> > better for you too.
> > 
> > 1) one thread that render screen
> > 2) this thread receives commands via one Channel and immediately
> > executes them

For what its worth, Yi uses an MVar on a buffer state to have a thread
redraw the screen only when the buffer is actually modified. This works
quite nicely:

        refreshLoop :: IO ()
        refreshLoop = repeatM_ $ do 
                        takeMVar editorModified
                        handleJust ioErrors (errorE.show) UI.refresh 

-- Don



More information about the Glasgow-haskell-users mailing list