private void CloseSubscriber(ISubscriber <T> subscriber, ICompletedState withState) { var f = withState as Failed; if (withState is Completed) { ReactiveStreamsCompliance.TryOnComplete(subscriber); } else if (f != null && !(f.Reason is ISpecViolation)) { ReactiveStreamsCompliance.TryOnError(subscriber, f.Reason); } }
private void ClosePublisher(ICompletedState withState) { SubscriptionTimeout.Cancel(); var prev = _state.Value; _state.Value = withState; if (prev is ICompletedState) { throw new IllegalStateException("Attempted to double shutdown publisher"); } if (prev is Attached) { var sub = ((Attached)prev).Subscriber; if (Subscriber == null) { ReactiveStreamsCompliance.TryOnSubscribe(sub, CancelledSubscription.Instance); } CloseSubscriber(sub, withState); } }