protected override void LoadStateCore(IOperatorStateReader reader) { base.LoadStateCore(reader); _hasValue = reader.Read <bool>(); _value = reader.Read <TSource>(); _id = reader.Read <ulong>(); var hasInner = reader.Read <bool>(); if (hasInner) { #pragma warning disable IDE0079 // Remove unnecessary suppression. #pragma warning disable CA2000 // Dispose objects before losing scope. (Observer will be owned by inner subscription.) var observer = new ThrottleObserver(this); var subscription = LoadInner <TThrottle>(reader, observer); observer.Subscription = subscription; _cancelable.Subscription = subscription; #pragma warning restore CA2000 #pragma warning restore IDE0079 } }
public void OnNext(TSource value) { var throttle = default(ISubscribable <TThrottle>); try { throttle = Params._throttleSelector(value); } catch (Exception error) { lock (_gate) { Output.OnError(error); Dispose(); } return; } ulong currentId; lock (_gate) { _hasValue = true; _value = value; _id = unchecked (_id + 1); currentId = _id; } try { #pragma warning disable IDE0079 // Remove unnecessary suppression. #pragma warning disable CA2000 // Dispose objects before losing scope. (Observer will be owned by inner subscription.) var observer = new ThrottleObserver(this, value, currentId); var subscription = SubscribeInner <TThrottle>(throttle, observer); observer.Subscription = subscription; SubscriptionInitializeVisitor.Subscribe(subscription); SubscriptionInitializeVisitor.SetContext(subscription, _context); _cancelable.Subscription = subscription; SubscriptionInitializeVisitor.Start(subscription); #pragma warning restore CA2000 #pragma warning restore IDE0079 } catch (Exception error) { lock (_gate) { Output.OnError(error); Dispose(); } } }
public override void OnNext(TSource value) { IObservable <TThrottle> throttle; try { throttle = _throttleSelector(value); } catch (Exception error) { lock (_gate) { ForwardOnError(error); } return; } ulong currentid; lock (_gate) { _hasValue = true; _value = value; _id = unchecked (_id + 1); currentid = _id; } Disposable.TrySetSerial(ref _serialCancelable, null); var newInnerObserver = new ThrottleObserver(this, value, currentid); newInnerObserver.SetResource(throttle.SubscribeSafe(newInnerObserver)); Disposable.TrySetSerial(ref _serialCancelable, newInnerObserver); }