logo       

cooperative threads with generators: msg#00112

gnome.gtk+.python

Subject: cooperative threads with generators


Hi all,

I've seen quite a few posts about threading problems in
this group and am surprised to see that nobody recommended
cooperative threading using generators. See
http://www.daa.com.au/pipermail/pygtk/2001-October/002056.html
and
http://www-106.ibm.com/developerworks/linux/library/l-pythrd.html

Advantages:
* Guaranteed to work regardless of underlying thread support
* Much simpler to code and debug, no need for locks, semaphores etc.
* Allows extremely efficient scheduling. Thread creation/deletion
overhead is minimal.

Disadvantages:
* Potentially long running or blocking operations (file.read etc)
need to be handled with care.

The flexible scheduling is especially useful. In my MDI app I
have a fifo queue for each document and the scheduler runs the
queue for the currently focused document before any others.

Stephen.
--
Stephen Kennedy <steve9000@xxxxxxxxxxxx>
http://meld.sf.net visual diff and merge

_______________________________________________
pygtk mailing list pygtk@xxxxxxxxxx
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise