Subject: | POE & Tk: Excessive CPU Usage |
Using POE and Tk to setup a window that doesn't do much uses lots of CPU. Some folks on the
POE mailing list have verified this problem with the attached example program. This seems to
happen on many (all?) platforms. I've verified it on Apple MAC, solaris, and various windows
boxes. I emailed to Rocco Caputo, and he took a look at it, but says the problem will take some
time to crack. He asked me to submit this report.
-Craig
Subject: | cputest.pl |
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use POE;
POE::Session->create
( inline_states =>
{ _start => \&ui_start,
ev_count => sub { $_[HEAP]->{counter}++; },
ev_clear => sub { $_[HEAP]->{counter} = 0; },
}
);
$poe_kernel->run();
exit 0;
sub ui_start {
my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];
$poe_main_window->Label( -text => "Counter" )->pack;
$heap->{counter} = 0;
$heap->{counter_widget} =
$poe_main_window->Label( -textvariable => \$heap->{counter} )->pack;
$poe_main_window->Button
( -text => "Count",
-command => $session->postback("ev_count")
)->pack;
$poe_main_window->Button
( -text => "Clear",
-command => $session->postback("ev_clear")
)->pack;
}