X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote.pm;h=7bb33c673cd1aba3bebc5728c8b028ab57e442a1;hp=cd3a36489ba39a5f205c8222f69e8cf495c88be0;hb=ad4f54b29c5f84aa010b456303b24647c0e28ae7;hpb=2065b08ba567dbf8c8370b69e3f5b2aa145efe23 diff --git a/lib/Object/Remote.pm b/lib/Object/Remote.pm index cd3a364..7bb33c6 100644 --- a/lib/Object/Remote.pm +++ b/lib/Object/Remote.pm @@ -9,6 +9,10 @@ has connection => (is => 'ro', required => 1); has id => (is => 'rwp'); +has disarmed_free => (is => 'rwp'); + +sub disarm_free { $_[0]->_set_disarmed_free(1); $_[0] } + sub proxy { bless({ remote => $_[0], method => 'call' }, 'Object::Remote::Proxy'); } @@ -23,7 +27,7 @@ sub BUILD { class_call => $args->{class}, $args->{constructor}||'new', @{$args->{args}||[]} ) - ) + )->{remote}->disarm_free->id ); } $self->connection->register_remote($self); @@ -48,12 +52,12 @@ sub _await { my $loop = $self->current_loop; $future->on_ready(sub { $loop->stop }); $loop->run; - $future->get; + ($future->get)[0]; } sub DEMOLISH { my ($self, $gd) = @_; - return if $gd; + return if $gd or $self->disarmed_free; $self->connection->send_free($self->id); }