},
);
-has on_close => (is => 'rw', default => sub {});
+has on_close => (is => 'rw', default => sub { CPS::Future->new });
has child_pid => (is => 'ro');
has remote_objects_by_id => (is => 'ro', default => sub { {} });
+has outstanding_futures => (is => 'ro', default => sub { {} });
+
has _json => (
is => 'lazy',
handles => {
unshift @call, $type => my $future = CPS::Future->new;
+ my $outstanding = $self->outstanding_futures;
+ $outstanding->{$future} = $future;
+ $future->on_ready(sub { delete $outstanding->{$future} });
+
$self->_send(\@call);
return $future;
}
}
} else {
+ Object::Remote->current_loop
+ ->unwatch_io(
+ handle => $self->receive_from_fh,
+ on_read_ready => 1
+ );
+ my $outstanding = $self->outstanding_futures;
+ $_->fail("Connection lost") for values %$outstanding;
+ %$outstanding = ();
$self->on_close->done();
}
}