6 has is_running => (is => 'rw', clearer => 'loop_stop');
8 has _read_watches => (is => 'ro', default => sub { {} });
9 has _read_select => (is => 'ro', default => sub { IO::Select->new });
12 my ($self, %watch) = @_;
13 my $fh = $watch{handle};
14 if (my $cb = $watch{on_read_ready}) {
15 $self->_read_select->add($fh);
16 $self->_read_watches->{$fh} = $cb;
21 my ($self, %watch) = @_;
22 my $fh = $watch{handle};
23 if ($watch{on_read_ready}) {
24 $self->_read_select->remove($fh);
25 delete $self->_read_watches->{$fh};
31 my $read = $self->_read_watches;
32 my ($readable) = IO::Select->select($self->_read_select, undef, undef, 0.5);
33 # I would love to trap errors in the select call but IO::Select doesn't
34 # differentiate between an error and a timeout.
36 foreach my $fh (@$readable) {
44 while ($self->is_running) {