moved Endpoint prop. to RemoteCapability

This commit is contained in:
Christian Köllner 2020-04-06 21:55:02 +02:00
parent e3b6fd5c62
commit 747d350b20
11 changed files with 6 additions and 27 deletions

View File

@ -16,8 +16,6 @@ namespace Capnp.Rpc
/// </summary> /// </summary>
protected abstract void ReleaseRemotely(); protected abstract void ReleaseRemotely();
internal abstract Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer); internal abstract Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer);
internal abstract IRpcEndpoint? Endpoint { get; }
internal abstract void AddRef(); internal abstract void AddRef();
internal abstract void Release(); internal abstract void Release();

View File

@ -28,8 +28,6 @@ namespace Capnp.Rpc
return call; return call;
} }
internal override IRpcEndpoint? Endpoint => _ep;
internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER capDesc) internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER capDesc)
{ {
if (endpoint == _ep) if (endpoint == _ep)

View File

@ -34,7 +34,5 @@ namespace Capnp.Rpc.Interception
writer.SenderHosted = endpoint.AllocateExport(MyVine, out bool _); writer.SenderHosted = endpoint.AllocateExport(MyVine, out bool _);
return null; return null;
} }
internal override IRpcEndpoint? Endpoint => null;
} }
} }

View File

@ -33,8 +33,6 @@ namespace Capnp.Rpc
_capTask = AwaitCap(); _capTask = AwaitCap();
} }
internal override IRpcEndpoint? Endpoint => null;
internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer)
{ {
if (WhenResolved.ReplacementTaskIsCompletedSuccessfully()) if (WhenResolved.ReplacementTaskIsCompletedSuccessfully())

View File

@ -29,8 +29,6 @@ namespace Capnp.Rpc
} }
internal override IRpcEndpoint? Endpoint => null;
public Task WhenResolved => _whenResolvedProxy; public Task WhenResolved => _whenResolvedProxy;
public T? GetResolvedCapability<T>() where T : class => _whenResolvedProxy.GetResolvedCapability<T>(); public T? GetResolvedCapability<T>() where T : class => _whenResolvedProxy.GetResolvedCapability<T>();

View File

@ -52,8 +52,6 @@ namespace Capnp.Rpc
return null; return null;
} }
internal override IRpcEndpoint? Endpoint => null;
protected override void ReleaseRemotely() protected override void ReleaseRemotely()
{ {
} }

View File

@ -23,8 +23,6 @@ namespace Capnp.Rpc
public override Task WhenResolved => _resolvedCap.Task; public override Task WhenResolved => _resolvedCap.Task;
public override T? GetResolvedCapability<T>() where T: class => _whenResolvedProxy.GetResolvedCapability<T>(); public override T? GetResolvedCapability<T>() where T: class => _whenResolvedProxy.GetResolvedCapability<T>();
internal override IRpcEndpoint? Endpoint => _ep;
internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer)
{ {
lock (_reentrancyBlocker) lock (_reentrancyBlocker)

View File

@ -174,8 +174,6 @@ namespace Capnp.Rpc
return call; return call;
} }
internal override IRpcEndpoint Endpoint => _ep;
internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer)
{ {
lock (_question.ReentrancyBlocker) lock (_question.ReentrancyBlocker)

View File

@ -13,6 +13,8 @@ namespace Capnp.Rpc
_ep = ep; _ep = ep;
} }
internal IRpcEndpoint Endpoint => _ep;
internal override IPromisedAnswer DoCall(ulong interfaceId, ushort methodId, DynamicSerializerState args) internal override IPromisedAnswer DoCall(ulong interfaceId, ushort methodId, DynamicSerializerState args)
{ {
var call = SetupMessage(args, interfaceId, methodId); var call = SetupMessage(args, interfaceId, methodId);

View File

@ -32,18 +32,11 @@ namespace Capnp.Rpc
protected IPromisedAnswer CallOnResolution(ulong interfaceId, ushort methodId, DynamicSerializerState args) protected IPromisedAnswer CallOnResolution(ulong interfaceId, ushort methodId, DynamicSerializerState args)
{ {
if (ResolvedCap == null) var resolvedCap = ResolvedCap!;
throw new InvalidOperationException("Capability not yet resolved, calling on resolution not possible");
try try
{ {
if (ResolvedCap.Endpoint!= null && ResolvedCap.Endpoint != _ep) if (resolvedCap is RemoteCapability ||
{
// Carol lives in a different Vat C.
throw new NotImplementedException("Sorry, level 3 RPC is not yet supported.");
}
if (ResolvedCap.Endpoint != null ||
//# Note that in the case where Carol actually lives in Vat B (i.e., the same vat that the promise //# Note that in the case where Carol actually lives in Vat B (i.e., the same vat that the promise
//# already pointed at), no embargo is needed, because the pipelined calls are delivered over the //# already pointed at), no embargo is needed, because the pipelined calls are delivered over the
//# same path as the later direct calls. //# same path as the later direct calls.
@ -58,7 +51,7 @@ namespace Capnp.Rpc
#if DebugEmbargos #if DebugEmbargos
Logger.LogDebug("Direct call"); Logger.LogDebug("Direct call");
#endif #endif
using var proxy = new Proxy(ResolvedCap); using var proxy = new Proxy(resolvedCap);
return proxy.Call(interfaceId, methodId, args, default); return proxy.Call(interfaceId, methodId, args, default);
} }
else else

View File

@ -891,7 +891,7 @@ namespace Capnp.Rpc
{ {
using var proxy = await t; using var proxy = await t;
if (proxy.ConsumedCap?.Endpoint == this) if (proxy.ConsumedCap is RemoteCapability remote && remote.Endpoint == this)
{ {
#if DebugEmbargos #if DebugEmbargos
Logger.LogDebug($"Sender loopback disembargo. Thread = {Thread.CurrentThread.Name}"); Logger.LogDebug($"Sender loopback disembargo. Thread = {Thread.CurrentThread.Name}");