| 1 | package POE::Loop::EV; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # EV.pm (libev) event loop bridge | ||||||||||||||||||||||||||||
| 4 | # $Id: EV.pm 27 2008-01-29 19:42:57Z andyg $ | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 137 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 137 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 137 | ▶ | use POE::Loop::PerlSignals; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 137 | ▶ | use EV; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 137 | our $VERSION = '0.15'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 137 | my %methods; | |||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub _backend_name { | ||||||||||||||||||||||||||
|
Subroutine
_backend_name: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | return undef unless defined( my $backend = shift ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | %methods = ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | EV::BACKEND_SELECT() => 'select', | ||||||||||||||||||||||||||||
| 18 | EV::BACKEND_POLL() => 'poll', | ||||||||||||||||||||||||||||
| 19 | EV::BACKEND_EPOLL() => 'epoll', | ||||||||||||||||||||||||||||
| 20 | EV::BACKEND_KQUEUE() => 'kqueue', | ||||||||||||||||||||||||||||
| 21 | EV::BACKEND_DEVPOLL() => 'devpoll', | ||||||||||||||||||||||||||||
| 22 | EV::BACKEND_PORT() => 'port', | ||||||||||||||||||||||||||||
| 23 | ) unless keys %methods; | ||||||||||||||||||||||||||||
| 24 | 1 | return $methods{ $backend }; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =for poe_tests | ||||||||||||||||||||||||||||
| 28 | use EV; | ||||||||||||||||||||||||||||
| 29 | BEGIN { $ENV{POE_EVENT_LOOP} = 'POE::Loop::EV'; $ENV{POE_LOOP_USES_POLL} = 1 if EV::backend() == EV::BACKEND_POLL(); } | ||||||||||||||||||||||||||||
| 30 | sub skip_tests { | ||||||||||||||||||||||||||||
| 31 | return "wheel_readwrite test disabled for 'kqueue'" | ||||||||||||||||||||||||||||
| 32 | if EV::backend() == EV::BACKEND_KQUEUE() && $_[0] eq 'wheel_readwrite'; | ||||||||||||||||||||||||||||
| 33 | if ($_[0] eq '00_info') { | ||||||||||||||||||||||||||||
| 34 | my %methods = ( # duplicated for generated tests | ||||||||||||||||||||||||||||
| 35 | EV::BACKEND_SELECT() => 'select', | ||||||||||||||||||||||||||||
| 36 | EV::BACKEND_POLL() => 'poll', | ||||||||||||||||||||||||||||
| 37 | EV::BACKEND_EPOLL() => 'epoll', | ||||||||||||||||||||||||||||
| 38 | EV::BACKEND_KQUEUE() => 'kqueue', | ||||||||||||||||||||||||||||
| 39 | EV::BACKEND_DEVPOLL() => 'devpoll', | ||||||||||||||||||||||||||||
| 40 | EV::BACKEND_PORT() => 'port', | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | my $method = $methods{ EV::backend() }; | ||||||||||||||||||||||||||||
| 43 | diag("Using default EV backend '$method'"); | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | return undef; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Everything plugs into POE::Kernel. | ||||||||||||||||||||||||||||
| 51 | package # hide me from PAUSE | ||||||||||||||||||||||||||||
| 52 | POE::Kernel; | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # Loop debugging | ||||||||||||||||||||||||||||
| 55 | 12970 | ▶ | sub EV_DEBUG () { $ENV{POE_EV_DEBUG} || 0 } | ||||||||||||||||||||||||||
|
Subroutine
EV_DEBUG: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # Global EV timer object | ||||||||||||||||||||||||||||
| 58 | my $_watcher_timer; | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # Global list of EV filehandle objects, indexed by fd number | ||||||||||||||||||||||||||||
| 61 | 137 | my @fileno_watcher; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 137 | my $_async_watcher; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 137 | my $DIE_MESSAGE; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | ############################################################################ | ||||||||||||||||||||||||||||
| 68 | # Initialization, Finalization, and the Loop itself | ||||||||||||||||||||||||||||
| 69 | ############################################################################ | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 201 | ▶ | sub loop_initialize { | ||||||||||||||||||||||||||
|
Subroutine
loop_initialize: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 201 | my $self = shift; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 201 | ▶ | if ( EV_DEBUG ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | my $method = POE::Loop::EV::_backend_name( EV::backend() ); | |||||||||||||||||||||||||||
| 76 | 0 | warn "loop_initialize, EV is using method: $method\n"; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # Set up the global timer object | ||||||||||||||||||||||||||||
| 80 | 201 | $_watcher_timer = EV::periodic( 0, 0, 0, \&_loop_timer_callback ); | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # Workaround so perl signals are handled | ||||||||||||||||||||||||||||
| 83 | 201 | ▶ | $_async_watcher = EV::check(sub { }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 201 | $EV::DIED = \&_die_handler; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # Timer callback to dispatch events. | ||||||||||||||||||||||||||||
| 89 | 1865 | ▶ | sub _loop_timer_callback { | ||||||||||||||||||||||||||
|
Subroutine
_loop_timer_callback: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 90 | 1865 | my $self = $poe_kernel; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1865 | ▶ | EV_DEBUG && warn "_loop_timer_callback, at " . time() . "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 1865 | $self->_data_ev_dispatch_due(); | |||||||||||||||||||||||||||
| 95 | 1865 | $self->_test_if_kernel_is_idle(); | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | # Transferring control back to EV; this is idle time. | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 184 | ▶ | sub loop_finalize { | ||||||||||||||||||||||||||
|
Subroutine
loop_finalize: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 184 | my $self = shift; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 184 | ▶ | EV_DEBUG && warn "loop_finalize\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 184 | foreach my $fd ( 0 .. $#fileno_watcher ) { | |||||||||||||||||||||||||||
| 106 | 2929 | ▶ | next unless defined $fileno_watcher[ $fd ]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 817 | foreach my $mode ( EV::READ, EV::WRITE ) { | |||||||||||||||||||||||||||
| 108 | 1634 | ▶ | if ( defined $fileno_watcher[ $fd ]->[ $mode ] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | POE::Kernel::_warn( | |||||||||||||||||||||||||||
| 110 | "Mode $mode watcher for fileno $fd is defined during loop finalize" | ||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 184 | $self->loop_ignore_all_signals(); | |||||||||||||||||||||||||||
| 117 | 184 | undef $_async_watcher; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub loop_attach_uidestroy { | ||||||||||||||||||||||||||
|
Subroutine
loop_attach_uidestroy: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | # does nothing, no UI | ||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub loop_do_timeslice { | ||||||||||||||||||||||||||
|
Subroutine
loop_do_timeslice: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | # does nothing | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 184 | ▶ | sub loop_run { | ||||||||||||||||||||||||||
|
Subroutine
loop_run: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 129 | 184 | ▶ | EV_DEBUG && warn "loop_run\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 184 | EV::run(); | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 184 | ▶ | if ( defined $DIE_MESSAGE ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | my $message = $DIE_MESSAGE; | |||||||||||||||||||||||||||
| 135 | 0 | undef $DIE_MESSAGE; | |||||||||||||||||||||||||||
| 136 | 0 | die $message; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 184 | ▶ | sub loop_halt { | ||||||||||||||||||||||||||
|
Subroutine
loop_halt: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 184 | ▶ | EV_DEBUG && warn "loop_halt\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 184 | $_watcher_timer->stop(); | |||||||||||||||||||||||||||
| 144 | 184 | undef $_watcher_timer; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 184 | EV::break(); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub _die_handler { | ||||||||||||||||||||||||||
|
Subroutine
_die_handler: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | EV_DEBUG && warn "_die_handler( $@ )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | # EV doesn't let you rethrow an error here, so we have | ||||||||||||||||||||||||||||
| 153 | # to stop the loop and get the error later | ||||||||||||||||||||||||||||
| 154 | 0 | $DIE_MESSAGE = $@; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | # This will cause the EV::run call in loop_run to return, | ||||||||||||||||||||||||||||
| 157 | # and cause the process to die. | ||||||||||||||||||||||||||||
| 158 | 0 | EV::break(); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | ############################################################################ | ||||||||||||||||||||||||||||
| 162 | # Timer code | ||||||||||||||||||||||||||||
| 163 | ############################################################################ | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 1464 | ▶ | sub loop_resume_time_watcher { | ||||||||||||||||||||||||||
|
Subroutine
loop_resume_time_watcher: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 1464 | my ( $self, $next_time ) = @_; | |||||||||||||||||||||||||||
| 167 | 1464 | ▶ | ( $_watcher_timer and $next_time ) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_watcher_timer and $next_time
MC/DC0%0/2
$_watcher_timer and $next_time
$_watcher_timer
$next_time
Truth table33%1/3
A and B
A= $_watcher_timerB= $next_time
| |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 1464 | ▶ | EV_DEBUG && warn "loop_resume_time_watcher( $next_time, in " . ( $next_time - time() ) . " )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 1464 | $_watcher_timer->set($next_time); | |||||||||||||||||||||||||||
| 172 | 1464 | $_watcher_timer->start(); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 1505 | ▶ | sub loop_reset_time_watcher { | ||||||||||||||||||||||||||
|
Subroutine
loop_reset_time_watcher: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 176 | 1505 | my ( $self, $next_time ) = @_; | |||||||||||||||||||||||||||
| 177 | 1505 | ▶ | ( $_watcher_timer and $next_time ) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_watcher_timer and $next_time
MC/DC0%0/2
$_watcher_timer and $next_time
$_watcher_timer
$next_time
Truth table33%1/3
A and B
A= $_watcher_timerB= $next_time
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 1505 | ▶ | EV_DEBUG && warn "loop_reset_time_watcher( $next_time, in " . ( $next_time - time() ) . " )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 1505 | $_watcher_timer->set($next_time); | |||||||||||||||||||||||||||
| 182 | 1505 | $_watcher_timer->start(); | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 650 | ▶ | sub loop_pause_time_watcher { | ||||||||||||||||||||||||||
|
Subroutine
loop_pause_time_watcher: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 186 | 650 | ▶ | $_watcher_timer or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 466 | ▶ | EV_DEBUG && warn "loop_pause_time_watcher()\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 466 | $_watcher_timer->stop(); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | ############################################################################ | ||||||||||||||||||||||||||||
| 194 | # Filehandle code | ||||||||||||||||||||||||||||
| 195 | ############################################################################ | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | # helper function, not a method | ||||||||||||||||||||||||||||
| 198 | 1317 | ▶ | sub _mode_to_ev { | ||||||||||||||||||||||||||
|
Subroutine
_mode_to_ev: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||
| 199 | 1317 | ▶ | return EV::READ if $_[0] == MODE_RD; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 556 | ▶ | return EV::WRITE if $_[0] == MODE_WR; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | ▶ | confess "POE::Loop::EV does not support MODE_EX" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | if $_[0] == MODE_EX; | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | confess "Unknown mode $_[0]"; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1317 | ▶ | sub loop_watch_filehandle { | ||||||||||||||||||||||||||
|
Subroutine
loop_watch_filehandle: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 209 | 1317 | my ( $self, $handle, $mode ) = @_; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 1317 | my $fileno = fileno($handle); | |||||||||||||||||||||||||||
| 212 | 1317 | my $watcher = $fileno_watcher[ $fileno ]->[ $mode ]; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 1317 | ▶ | if ( defined $watcher ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 0 | $watcher->stop(); | |||||||||||||||||||||||||||
| 216 | 0 | undef $fileno_watcher[ $fileno ]->[ $mode ]; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 1317 | ▶ | EV_DEBUG && warn "loop_watch_filehandle( $handle ($fileno), $mode )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 1317 | $fileno_watcher[ $fileno ]->[ $mode ] = EV::io( | |||||||||||||||||||||||||||
| 222 | $fileno, | ||||||||||||||||||||||||||||
| 223 | _mode_to_ev($mode), | ||||||||||||||||||||||||||||
| 224 | \&_loop_filehandle_callback, | ||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 1176 | ▶ | sub loop_ignore_filehandle { | ||||||||||||||||||||||||||
|
Subroutine
loop_ignore_filehandle: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 229 | 1176 | my ( $self, $handle, $mode ) = @_; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 1176 | my $fileno = fileno($handle); | |||||||||||||||||||||||||||
| 232 | 1176 | my $watcher = $fileno_watcher[ $fileno ]->[ $mode ]; | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 1176 | ▶ | return if !defined $watcher; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 1176 | ▶ | EV_DEBUG && warn "loop_ignore_filehandle( $handle ($fileno), $mode )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 1176 | $watcher->stop(); | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 1176 | undef $fileno_watcher[ $fileno ]->[ $mode ]; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 1144 | ▶ | sub loop_pause_filehandle { | ||||||||||||||||||||||||||
|
Subroutine
loop_pause_filehandle: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 244 | 1144 | my ( $self, $handle, $mode ) = @_; | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 1144 | my $fileno = fileno($handle); | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 1144 | $fileno_watcher[ $fileno ]->[ $mode ]->stop(); | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 1144 | ▶ | EV_DEBUG && warn "loop_pause_filehandle( $handle ($fileno), $mode )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 988 | ▶ | sub loop_resume_filehandle { | ||||||||||||||||||||||||||
|
Subroutine
loop_resume_filehandle: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 254 | 988 | my ( $self, $handle, $mode ) = @_; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 988 | my $fileno = fileno($handle); | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 988 | $fileno_watcher[ $fileno ]->[ $mode ]->start(); | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 988 | ▶ | EV_DEBUG && warn "loop_resume_filehandle( $handle ($fileno), $mode )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 2292 | ▶ | sub _loop_filehandle_callback { | ||||||||||||||||||||||||||
|
Subroutine
_loop_filehandle_callback: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 264 | 2292 | my ( $watcher, $ev_mode ) = @_; | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 2292 | ▶ | EV_DEBUG && warn "_loop_filehandle_callback( " . $watcher->fh . ", $ev_mode )\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 2292 | ▶ | my $mode = ( $ev_mode == EV::READ ) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 269 | ? MODE_RD | ||||||||||||||||||||||||||||
| 270 | : ( $ev_mode == EV::WRITE ) | ||||||||||||||||||||||||||||
| 271 | ? MODE_WR | ||||||||||||||||||||||||||||
| 272 | : confess "Invalid mode occured in POE::Loop::EV IO callback: $ev_mode"; | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | # ->fh is actually the fileno, since that's what we called EV::io with | ||||||||||||||||||||||||||||
| 275 | 2292 | $poe_kernel->_data_handle_enqueue_ready( $mode, $watcher->fh ); | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 2292 | $poe_kernel->_test_if_kernel_is_idle(); | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 137 | 1; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | __END__ | ||||||||||||||||||||||||||||