Smile-n-Nod has asked for the wisdom of the Perl Monks concerning the following question:
I have a GUI app (written in Perl/Tk) that uses a few dozen threads and the Boss/Worker model to manage background tasks. The app runs very slowly unless the threads sleep periodically (using the select command), in which case the GUI runs very quickly. What is going on?
Here is an untested code snippet:
while (1) { eval { if (my $key = $Queue->dequeue_nb) { do_something(); } }; if ($@) { LOG("problem"); } select undef, undef, undef, 1.00; }
If I comment out the select command, the GUI runs an order of magnitude more slowly. What is the cause of this behavior?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GUI in Perl/Tk runs slow unless threads sleep periodically
by GrandFather (Saint) on Mar 23, 2011 at 23:06 UTC | |
|
Re: GUI in Perl/Tk runs slow unless threads sleep periodically
by BrowserUk (Patriarch) on Mar 24, 2011 at 00:12 UTC | |
by Smile-n-Nod (Initiate) on Mar 24, 2011 at 16:29 UTC | |
by BrowserUk (Patriarch) on Mar 24, 2011 at 16:50 UTC | |
|
Re: GUI in Perl/Tk runs slow unless threads sleep periodically
by Anonymous Monk on Mar 24, 2011 at 00:11 UTC |