… | |
… | |
285 | } |
285 | } |
286 | |
286 | |
287 | sub io { |
287 | sub io { |
288 | my ($class, %arg) = @_; |
288 | my ($class, %arg) = @_; |
289 | |
289 | |
290 | # cygwin requires the fh mode to be matching, unix doesn't |
290 | # POE itself might do the right thing, but some POE backends don't, |
|
|
291 | # so do the safe thing, it's not as if this will slow us down |
|
|
292 | # any further *g* |
291 | my ($fh, $pee) = AnyEvent::_dupfh $arg{poll}, $arg{fh}, "select_read", "select_write"; |
293 | my ($fh, $pee) = AnyEvent::_dupfh $arg{poll}, $arg{fh}, "select_read", "select_write"; |
292 | |
294 | |
293 | my $cb = $arg{cb}; |
295 | my $cb = $arg{cb}; |
294 | |
296 | |
295 | my $session = POE::Session->create ( |
297 | my $session = POE::Session->create ( |
296 | inline_states => { |
298 | inline_states => { |
297 | _start => sub { |
|
|
298 | $_[KERNEL]->$pee ($fh => "ready"); |
299 | _start => sub { $_[KERNEL]->$pee ($fh => "ready") }, |
299 | }, |
|
|
300 | ready => sub { |
300 | ready => sub { $cb->() }, |
301 | $cb->(); |
|
|
302 | }, |
|
|
303 | stop => sub { |
|
|
304 | $_[KERNEL]->$pee ($fh); |
301 | stop => sub { $_[KERNEL]->$pee ($fh) }, |
305 | }, |
|
|
306 | }, |
302 | }, |
307 | ); |
303 | ); |
308 | bless \\$session, "AnyEvent::Impl::POE" |
304 | bless \\$session, "AnyEvent::Impl::POE" |
309 | } |
305 | } |
310 | |
306 | |