From: Matt S Trout Date: Mon, 11 Jun 2012 18:20:58 +0000 (+0100) Subject: eliminate is_ready attr in favour of ready_future X-Git-Tag: v0.001001~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e441f00ec2896d31dae9f06e8735ac8343a16f22;p=scpubgit%2FObject-Remote.git eliminate is_ready attr in favour of ready_future --- diff --git a/bin/object-remote-node b/bin/object-remote-node index c5c9515..1ab639d 100755 --- a/bin/object-remote-node +++ b/bin/object-remote-node @@ -7,7 +7,7 @@ use CPS::Future; my $c = Object::Remote::Connector::STDIO->new->connect; -$c->_set_is_ready(1); +$c->ready_future->done; my $loop = Object::Remote->current_loop; diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index f466452..e3cb452 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -35,11 +35,6 @@ has on_close => (is => 'rw', default => sub { CPS::Future->new }); has child_pid => (is => 'ro'); -has is_ready => (is => 'rwp', trigger => sub { - my ($self, $value) = @_; - $self->ready_future->done if $value; -}); - has ready_future => (is => 'lazy'); sub _build_ready_future { CPS::Future->new } @@ -127,7 +122,6 @@ sub register_remote { sub await_ready { my ($self) = @_; - return if $self->is_ready; await_future($self->ready_future); } @@ -162,7 +156,7 @@ sub send_discard { sub _send { my ($self, $to_send) = @_; - $self->await_ready unless $self->is_ready; + $self->await_ready; print { $self->send_to_fh } $self->_serialize($to_send)."\n"; } @@ -216,7 +210,7 @@ sub _deobjectify { sub _receive_data_from { my ($self, $fh) = @_; my $rb = $self->_receive_data_buffer; - my $ready = $self->is_ready; + my $ready = $self->ready_future->is_ready; if (sysread($fh, $$rb, 1024, length($$rb)) > 0) { while ($$rb =~ s/^(.*)\n//) { if ($ready) { @@ -225,7 +219,7 @@ sub _receive_data_from { my $line = $1; die "New remote container did not send Shere - got ${line}" unless $line eq "Shere"; - $self->_set_is_ready($ready = 1); + $self->ready_future->done; } } } else {