I'm not familiar enough with yi to know where to put the split, but yeah, approach sounds exactly right. Somewhere, you'll have some code that looks just about like this.
splitPango = do done <- newEmptyMVar chan <- newChan forkIO $ drawPango done chan --or forkOS, haskell concurrency is neat, you can use them interchangeably. return (done,chan) drawPangoLoop done chan = continue <- isEmptyMVar done if continue then do view <- readChan chan empty <- isEmptyChan chan if empty then do goDoTheNormalWork view drawPangoLoop chan else drawPangoLoop chan --skip ahead to newer events else return () switch the old system to write events to the chan, and put a () in done to terminate... Haskell threading is really nice, if you can find a place for IO it should be pretty easy to do just what you need. The only real worry is that you actually need all the intermediate steps to reconstruct the state, but i think yi sends enough do do the whole view. Jason On Jul 29, 2009, at 7:53 PM, Jeff Wheeler wrote: > > I've been reading back through issue #265 [1], and I expect that most > of these comments apply to Pango. Particularly, drawing in a separate > thread would be useful, I expect, and perhaps doing the syntax > highlighting separately would be useful, too. > > I'm not at all experienced in threading in Haskell, but I'm doing my > best to learn about how this applies to the Pango UI. Correct me if > I'm wrong, but I think we're currently going through the cycle of > redrawing all the text at each action (even cursor movement), all > synchronously so that it has to be completely redrawn before the next > action can be handled. This would explain why even things that don't > affect syntax highlight --- such as just moving the cursor down > several rows --- is sluggish. > > I don't know whether rendering asynchronously serves any greater > advantage without smarter threading, because I'm not experiencing the > window flashing between renders. A threaded solution could throw away > incomplete solutions while new actions arrive. > > Does this all make sense, or am I completely off-target here? > > Jeff Wheeler > > [1] http://code.google.com/p/yi-editor/issues/detail?id=265 > > --~--~---------~--~----~------------~-------~--~----~ Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel -~----------~----~----~----~------~----~------~--~---