add call_free/call_discard_free to save a message on future responses
Matt S Trout [Mon, 14 May 2012 13:28:39 +0000 (13:28 +0000)]
lib/Object/Remote.pm
lib/Object/Remote/Connection.pm

index 7bb33c6..a815501 100644 (file)
@@ -47,6 +47,12 @@ sub call_discard {
   $self->connection->send_discard(call => $self->id, $method, @args);
 }
 
+sub call_discard_free {
+  my ($self, $method, @args) = @_;
+  $self->disarm_free;
+  $self->connection->send_discard(call_free => $self->id, $method, @args);
+}
+
 sub _await {
   my ($self, $future) = @_;
   my $loop = $self->current_loop;
index 7ab6b1f..09d5712 100644 (file)
@@ -163,15 +163,21 @@ sub receive_free {
 
 sub receive_call {
   my ($self, $future, $id, @rest) = @_;
-  $future->{method} = 'call_discard';
+  $future->{method} = 'call_discard_free';
   my $local = $self->local_objects_by_id->{$id}
     or do { $future->fail("No such object $id"); return };
   $self->_invoke($future, $local, @rest);
 }
 
+sub receive_call_free {
+  my ($self, $future, $id, @rest) = @_;
+  $self->receive_call($future, $id, @rest);
+  $self->receive_free($id);
+}
+
 sub receive_class_call {
   my ($self, $future, $class, @rest) = @_;
-  $future->{method} = 'call_discard';
+  $future->{method} = 'call_discard_free';
   eval { use_module($class) }
     or do { $future->fail("Error loading ${class}: $@"); return };
   $self->_invoke($future, $class, @rest);