Commit da3bff12 authored by Josh Kunz's avatar Josh Kunz

Adds optional interface to get futures directly from recv_wait

parent 03f7aecc
......@@ -730,16 +730,21 @@ class RP(Capability):
reply = self.protocol._invoke(self, cn_pb.CPOBJMETHOD_RP_RECV, None)
return self._gen_recv_result(reply)
def _recv_wait_future(self):
"""This is an internal operation intended for advanced usage. Instead
of returning a capability result, it returns a future for the result
that can be collected using the recv method of the future."""
future = self.protocol._invoke(self, cn_pb.CPOBJMETHOD_RP_RECV_WAIT, None,
register_notify=True)
return future
def recv_wait(self, timeout=None):
"""Same as a recv operation, but it will wait until a capability is
sent on the membrane instead of throwing an error.
Returns the received object capability.
"""
future = self.protocol._invoke(self, cn_pb.CPOBJMETHOD_RP_RECV_WAIT, None,
register_notify=True)
# The future could be directly exposed, but for now, we'll just always
# block
future = self._recv_wait_future()
result = future.recv(timeout=timeout)
return self._gen_recv_result(result)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment