1 package Object::Remote::Handle;
3 use Object::Remote::Proxy;
4 use Scalar::Util qw(weaken blessed);
5 use Object::Remote::Future;
6 #must find way to exclude certain log events
7 #from being forwarded - log events generated in
8 #response to log events cause exploding
9 #use Object::Remote::Logging qw(:log);
10 use Module::Runtime qw(use_module);
14 is => 'ro', required => 1,
18 : use_module('Object::Remote::Connection')->new_from_spec($_[0])
22 has id => (is => 'rwp');
24 has disarmed_free => (is => 'rwp');
26 sub disarm_free { $_[0]->_set_disarmed_free(1); $_[0] }
29 bless({ remote => $_[0], method => 'call' }, 'Object::Remote::Proxy');
33 my ($self, $args) = @_;
34 # log_debug { "constructing instance of " . ref($self) };
38 die "No id supplied and no class either" unless $args->{class};
39 ref($_) eq 'HASH' and $_ = [ %$_ ] for $args->{args};
42 $self->connection->send_class_call(
44 $args->{constructor}||'new', @{$args->{args}||[]}
46 )->{remote}->disarm_free->id
49 # log_trace { "finished constructing " . ref($self) };
50 $self->connection->register_remote($self);
54 my ($self, $method, @args) = @_;
56 $method = "start::${method}" if (caller(0)||'') eq 'start';
58 $self->connection->send(call => $self->id, $w, $method, @args)
63 my ($self, $method, @args) = @_;
64 $self->connection->send_discard(call => $self->id, $method, @args);
67 sub call_discard_free {
68 my ($self, $method, @args) = @_;
70 $self->connection->send_discard(call_free => $self->id, $method, @args);
75 return if $gd or $self->disarmed_free;
76 $self->connection->send_free($self->id);