+ - add Tak->loop_upgrade
- Provide a $client in repl objects
- Support for -l/--local in Tak::Script
sub loop { $loop ||= Tak::Loop->new }
+sub loop_upgrade {
+ require IO::Async::Loop;
+ my $new_loop = IO::Async::Loop->new;
+ $loop->pass_watches_to($new_loop) if $loop;
+ $loop = $new_loop;
+}
+
sub loop_until {
my ($class, $done) = @_;
return if $done;
- my $loop = $class->loop;
- $loop->loop_once until $_[1];
+ $class->loop->loop_once until $_[1];
}
sub await_all {
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};