internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { if (WhenResolved.IsCompletedSuccessfully) { WhenResolved.Result.Export(endpoint, writer); } else { this.ExportAsSenderPromise(endpoint, writer); } }
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { if (WhenResolved.IsCompleted && WhenResolved.WrappedTask.ReplacementTaskIsCompletedSuccessfully()) { using var proxy = GetResolvedCapability <BareProxy>() !; return(proxy.Export(endpoint, writer)); } else { return(this.ExportAsSenderPromise(endpoint, writer)); } }
internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER capDesc) { if (endpoint == _ep) { capDesc.which = CapDescriptor.WHICH.ReceiverHosted; capDesc.ReceiverHosted = _remoteId; } else { capDesc.which = CapDescriptor.WHICH.SenderHosted; capDesc.SenderHosted = endpoint.AllocateExport(Vine.Create(this), out var _); } }
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER capDesc) { if (endpoint == _ep) { capDesc.which = CapDescriptor.WHICH.ReceiverHosted; capDesc.ReceiverHosted = _remoteId; } else { capDesc.which = CapDescriptor.WHICH.SenderHosted; capDesc.SenderHosted = endpoint.AllocateExport(AsSkeleton(), out var _); } return(null); }
internal void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { if (_disposedValue) { throw new ObjectDisposedException(nameof(Proxy)); } if (ConsumedCap == null) { writer.which = CapDescriptor.WHICH.None; } else { ConsumedCap.Export(endpoint, writer); } }
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { lock (_reentrancyBlocker) { if (_resolvedCap.Task.ReplacementTaskIsCompletedSuccessfully()) { using var proxy = new Proxy(_resolvedCap.Task.Result); proxy.Export(endpoint, writer); } else { if (_ep == endpoint) { writer.which = CapDescriptor.WHICH.ReceiverHosted; writer.ReceiverHosted = _remoteId; Debug.Assert(!_released); ++_pendingCallsOnPromise; return(() => { bool release = false; lock (_reentrancyBlocker) { if (--_pendingCallsOnPromise == 0 && _resolvedCap.Task.IsCompleted) { _released = true; release = true; } } if (release) { _ep.ReleaseImport(_remoteId); } }); } else { this.ExportAsSenderPromise(endpoint, writer); } } } return(null); }
internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { lock (_question.ReentrancyBlocker) { if (_question.StateFlags.HasFlag(PendingQuestion.State.Disposed)) { throw new ObjectDisposedException(nameof(PendingQuestion)); } if (_question.StateFlags.HasFlag(PendingQuestion.State.Returned)) { ResolvedCap.Export(endpoint, writer); } else { if (_question.StateFlags.HasFlag(PendingQuestion.State.FinishRequested)) { throw new InvalidOperationException("Finish request was already sent"); } if (endpoint == _ep) { writer.which = CapDescriptor.WHICH.ReceiverAnswer; _access.Serialize(writer.ReceiverAnswer); writer.ReceiverAnswer.QuestionId = _question.QuestionId; } else if (_question.IsTailCall) { // FIXME: Resource management! We should prevent finishing this // cap as long as it is exported. Unfortunately, we cannot determine // when it gets removed from the export table. var vine = Vine.Create(this); uint id = endpoint.AllocateExport(vine, out bool first); writer.which = CapDescriptor.WHICH.SenderHosted; writer.SenderHosted = id; } else { this.ExportAsSenderPromise(endpoint, writer); } } } }
internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { lock (_reentrancyBlocker) { if (_resolvedCap.Task.IsCompletedSuccessfully) { _resolvedCap.Task.Result.Export(endpoint, writer); } else { if (_ep == endpoint) { writer.which = CapDescriptor.WHICH.ReceiverHosted; writer.ReceiverHosted = _remoteId; Debug.Assert(!_released); ++_pendingCallsOnPromise; _ep.RequestPostAction(() => { bool release = false; lock (_reentrancyBlocker) { if (--_pendingCallsOnPromise == 0 && _resolvedCap.Task.IsCompleted) { _released = true; release = true; } } if (release) { _ep.ReleaseImport(_remoteId); } }); } else { this.ExportAsSenderPromise(endpoint, writer); } } } }
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { lock (_question.ReentrancyBlocker) { if (_question.StateFlags.HasFlag(PendingQuestion.State.CanceledByDispose)) { throw new ObjectDisposedException(nameof(PendingQuestion)); } if (_question.StateFlags.HasFlag(PendingQuestion.State.Returned) && !_question.IsTailCall) { ResolvedCap !.Export(endpoint, writer); } else { if (_question.StateFlags.HasFlag(PendingQuestion.State.FinishRequested)) { throw new InvalidOperationException("Finish request was already sent"); } if (endpoint == _ep) { writer.which = CapDescriptor.WHICH.ReceiverAnswer; _access.Serialize(writer.ReceiverAnswer !); writer.ReceiverAnswer !.QuestionId = _question.QuestionId; } else if (_question.IsTailCall) { uint id = endpoint.AllocateExport(AsSkeleton(), out bool first); writer.which = CapDescriptor.WHICH.SenderHosted; writer.SenderHosted = id; } else { return(this.ExportAsSenderPromise(endpoint, writer)); } } } return(null); }
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { if (_whenResolvedProxy.IsCompleted) { try { _whenResolvedProxy.Result.Export(endpoint, writer); } catch (AggregateException exception) { throw exception.InnerException !; } return(null); } else { return(this.ExportAsSenderPromise(endpoint, writer)); } }
internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { if (_answer.IsCompleted) { DeserializerState result; try { result = _answer.Result; } catch (AggregateException exception) { throw exception.InnerException; } using (var proxy = new Proxy(_access.Eval(result))) { proxy.Export(endpoint, writer); } } else { this.ExportAsSenderPromise(endpoint, writer); } }
internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER capDesc) { capDesc.which = CapDescriptor.WHICH.SenderHosted; capDesc.SenderHosted = endpoint.AllocateExport(ProvidedCap, out bool _); }
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { writer.which = CapDescriptor.WHICH.None; return(null); }
internal override void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { writer.which = CapDescriptor.WHICH.SenderHosted; writer.SenderHosted = endpoint.AllocateExport(MyVine, out bool _); }
public static void ExportAsSenderPromise <T>(this T cap, IRpcEndpoint endpoint, CapDescriptor.WRITER writer) where T : ConsumedCapability, IResolvingCapability { var vine = Vine.Create(cap); uint preliminaryId = endpoint.AllocateExport(vine, out bool first); writer.which = CapDescriptor.WHICH.SenderPromise; writer.SenderPromise = preliminaryId; if (first) { endpoint.RequestPostAction(async() => { try { var resolvedCap = await cap.WhenResolved; endpoint.Resolve(preliminaryId, vine, () => resolvedCap.ConsumedCap !); } catch (System.Exception exception) { endpoint.Resolve(preliminaryId, vine, () => throw exception); } }); } }
public static Action?ExportAsSenderPromise <T>(this T cap, IRpcEndpoint endpoint, CapDescriptor.WRITER writer) where T : ConsumedCapability, IResolvingCapability { var vine = cap.AsSkeleton(); uint preliminaryId = endpoint.AllocateExport(vine, out bool first); writer.which = CapDescriptor.WHICH.SenderPromise; writer.SenderPromise = preliminaryId; if (first) { return(async() => { try { await cap.WhenResolved; using var proxy = cap.GetResolvedCapability <BareProxy>() !; var resolvedCap = await Unwrap(proxy.ConsumedCap); endpoint.Resolve(preliminaryId, vine, () => resolvedCap !); } catch (System.Exception exception) { endpoint.Resolve(preliminaryId, vine, () => throw exception); } }); } return(null); }
internal abstract void Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer);
internal override Action?Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer) { writer.which = CapDescriptor.WHICH.SenderHosted; writer.SenderHosted = endpoint.AllocateExport(AsSkeleton(), out bool _); return(null); }