Hi, I have a question regarding efficient programming in a multithreaded environment. Our scenario deals with Qt, but the problem is a general one.
Our setup is a typical multithreaded one: We have a number of worker threads and one GUI thread, both communicating via a Queue. The problem is: How not to waste CPU resources by using a timer to poll the communication Queue from within the GUI thread. Some more information: Since we're targetting a PDA with Qt/Embedded, we're using PyQt. The PDA runs a non-threaded Qt/Embedded 2.3.4 and will for quite a long time. Qt/E 2.3.4 is _not_ thread-safe, so all calls to Qt must be done from same thread. This also means, it's unfortunately not possible to call QApplication.postEvent() from a worker thread to make the GUI thread to check for a new message in the Queue. How is this handled in low-level programs? In C++, I would use a pipe for the communication and would overload the main event loop adding a pipe file descriptor to the select() call. This way I can simultaneously wait for gui events and non-gui events without wasting CPU resources. In Python, the situation is different, since I can't overload the main loop - it would be much to slow (let alone, that the internal gui main loop functions are private and thus are not exported). Even if I could, in Python I'd rather use Queues than pipes - and a Queue is nothing which can just be added to a select call. Could you share some insights with me? Cheers, Mickey. -- :M: -------------------------------------------------------------------------- Dipl.-Inf. Michael 'Mickey' Lauer [EMAIL PROTECTED] Raum 10b - ++49 69 798 28358 Fachbereich Informatik und Biologie -------------------------------------------------------------------------- _______________________________________________ PyKDE mailing list [EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
