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>
protected abstract void ReleaseRemotely();
internal abstract Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer);
internal abstract IRpcEndpoint? Endpoint { get; }
internal abstract void AddRef();
internal abstract void Release();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,8 +23,6 @@ namespace Capnp.Rpc
public override Task WhenResolved => _resolvedCap.Task;
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)
{
lock (_reentrancyBlocker)

View File

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

View File

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

View File

@ -32,18 +32,11 @@ namespace Capnp.Rpc
protected IPromisedAnswer CallOnResolution(ulong interfaceId, ushort methodId, DynamicSerializerState args)
{
if (ResolvedCap == null)
throw new InvalidOperationException("Capability not yet resolved, calling on resolution not possible");
var resolvedCap = ResolvedCap!;
try
{
if (ResolvedCap.Endpoint!= null && ResolvedCap.Endpoint != _ep)
{
// Carol lives in a different Vat C.
throw new NotImplementedException("Sorry, level 3 RPC is not yet supported.");
}
if (ResolvedCap.Endpoint != null ||
if (resolvedCap is RemoteCapability ||
//# 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
//# same path as the later direct calls.
@ -58,7 +51,7 @@ namespace Capnp.Rpc
#if DebugEmbargos
Logger.LogDebug("Direct call");
#endif
using var proxy = new Proxy(ResolvedCap);
using var proxy = new Proxy(resolvedCap);
return proxy.Call(interfaceId, methodId, args, default);
}
else

View File

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