[Haskell-cafe] GUI and background processing

2009-06-01 Thread Dmitry V'yal

Greetings, fellow haskellers.

Currently I'm writing some kind of web crawler in haskell with gtk2hs gui.

All network operations are run in separate thread, but sometimes input 
from user is needed. Afaik, gtk2hs is not thread safe, so I came up with 
following:


I create two mvars, A and B, one for question, one for answer. Worker 
thread puts question in A and blocks trying to take B. Gui thread checks 
for question by polling with tryTakeMVar. Then question is ready, it 
asks user and puts his answer into B. Worker awakens and continues 
processing.


Also, for progress report, I use a Chan which is written to by worker 
and is read by polling by gui thread.


This scheme works, but I don't like it. All these mvars and chans create 
too much clutter, and polling looks rather ugly too. Is there a better 
way for implementing similar patterns of interaction?


Best regards,
Dmitry.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GUI and background processing

2009-06-01 Thread Bulat Ziganshin
Hello Dmitry,

Monday, June 1, 2009, 4:24:36 PM, you wrote:

 All network operations are run in separate thread, but sometimes input
 from user is needed. Afaik, gtk2hs is not thread safe, so I came up with

look for postGUISync and postGUIASync


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe