loop_upgrade
[scpubgit/Tak.git] / lib / Tak / Loop.pm
index a1a4db3..09af744 100644 (file)
@@ -8,6 +8,16 @@ has is_running => (is => 'rw', clearer => 'loop_stop');
 has _read_watches => (is => 'ro', default => sub { {} });
 has _read_select => (is => 'ro', default => sub { IO::Select->new });
 
+sub pass_watches_to {
+  my ($self, $new_loop) = @_;
+  foreach my $fh ($self->_read_select->handles) {
+    $new_loop->watch_io(
+      handle => $fh,
+      on_read_ready => $self->_read_watches->{$fh}
+    );
+  }
+}
+
 sub watch_io {
   my ($self, %watch) = @_;
   my $fh = $watch{handle};