/usr/share/perl5/POE/Loop/TkCommon.pm is in libpoe-loop-tk-perl 1.305-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | # The common bits of our system-specific Tk event loops. This is
# everything but file handling.
# Empty package to appease perl.
package POE::Loop::TkCommon;
# Include common signal handling.
use POE::Loop::PerlSignals;
use vars qw($VERSION);
$VERSION = '1.305'; # NOTE - Should be #.### (three decimal places)
use Tk 800.021;
use 5.00503;
# Everything plugs into POE::Kernel.
package POE::Kernel;
use strict;
use Tk qw(DoOneEvent DONT_WAIT ALL_EVENTS);
my $_watcher_time;
#------------------------------------------------------------------------------
# Signal handler maintenance functions.
sub loop_attach_uidestroy {
my ($self, $window) = @_;
$window->OnDestroy(
sub {
if ($self->_data_ses_count()) {
$self->_dispatch_event(
$self, $self,
EN_SIGNAL, ET_SIGNAL, [ 'UIDESTROY' ],
__FILE__, __LINE__, undef, time(), -__LINE__
);
}
}
);
}
#------------------------------------------------------------------------------
# Maintain time watchers.
sub loop_resume_time_watcher {
my ($self, $next_time) = @_;
$self->loop_pause_time_watcher();
my $timeout = $next_time - time();
if ( $timeout < 0 ) {
$timeout = "idle";
} else {
$timeout *= 1000;
}
$_watcher_time = $poe_main_window->after(
$timeout, [ sub { } ]
);
}
sub loop_reset_time_watcher {
my ($self, $next_time) = @_;
$self->loop_resume_time_watcher($next_time);
}
sub loop_pause_time_watcher {
my $self = shift;
if (defined $_watcher_time) {
$_watcher_time->cancel() if $_watcher_time->can("cancel");
$_watcher_time = undef;
}
}
# TODO - Ton Hospel's Tk event loop doesn't mix alarms and immediate
# events. Rather, it keeps a list of immediate events and defers
# queuing of alarms to something else.
#
# sub loop {
# # Extra test without alarm handling makes alarm priority normal
# (@immediate && run_signals),
# DoOneEvent(DONT_WAIT | FILE_EVENTS | WINDOW_EVENTS) while
# (@immediate && run_signals), !@loops && DoOneEvent;
# return shift @loops;
# }
#
# The immediate events are dispatched in a chunk between calls to Tk's
# event loop. He uses a double buffer: As events are processed in
# @immediate, new ones go into a different list. Once @immediate is
# exhausted, the second list is copied in.
#
# The double buffered queue means that @immediate is alternately
# exhausted and filled. It's impossible to fill @immediate while it's
# being processed, so sub handle_foo { yield("foo") } won't run
# forever.
#
# This has a side effect of deferring any alarms until after
# @immediate is exhausted. I suspect the semantics are similar to
# POE's queue anyway, however.
#------------------------------------------------------------------------------
# Tk traps errors in an effort to survive them. However, since POE
# does not, this leaves us in a strange, inconsistent state. Here we
# re-trap the errors and rethrow them as UIDESTROY.
sub Tk::Error {
my $window = shift;
my $error = shift;
if (Tk::Exists($window)) {
my $grab = $window->grab('current');
$grab->Unbusy if defined $grab;
}
chomp($error);
POE::Kernel::_warn "Tk::Error: $error\n " . join("\n ",@_)."\n";
if ($poe_kernel->_data_ses_count()) {
$poe_kernel->_dispatch_event(
$poe_kernel, $poe_kernel,
EN_SIGNAL, ET_SIGNAL, [ 'UIDESTROY' ],
__FILE__, __LINE__, undef, time(), -__LINE__
);
}
}
#------------------------------------------------------------------------------
# The event loop itself.
sub loop_do_timeslice {
my $self = shift;
# Check for a hung kernel.
$self->_test_if_kernel_is_idle();
DoOneEvent(ALL_EVENTS);
# Dispatch whatever events are due. Update the next dispatch time.
$self->_data_ev_dispatch_due();
}
sub loop_run {
my $self = shift;
# Run for as long as there are sessions to service.
while ($self->_data_ses_count()) {
$self->loop_do_timeslice();
}
}
sub loop_halt {
# Do nothing.
}
1;
__END__
=head1 NAME
POE::Loop::TkCommon - common code between the POE/Tk event loop bridges
=head1 SYNOPSIS
See L<POE::Loop>.
=head1 DESCRIPTION
POE::Loop::TkCommon is a mix-in class that supports common features
between POE::Loop::Tk and POE::Loop::TkActiveState. All Tk bridges
implement the interface documented in POE::Loop. Therefore, please
see L<POE::Loop> for more details.
=head1 SEE ALSO
L<POE>, L<POE::Loop>, L<Tk>, L<POE::Loop::Tk>,
L<POE::Loop::TkActiveState>
=head1 AUTHORS & LICENSING
Please see L<POE> for more information about authors, contributors,
and POE's licensing.
=cut
# rocco // vim: ts=2 sw=2 expandtab
# TODO - Edit.
|