public WindowExactObserver(ISignalObserver <IObservableSource <T> > downstream, int size) { this.downstream = downstream; this.size = size; this.onTerminate = TerminateWindow; Volatile.Write(ref active, 1); }
/// <summary> /// Subscribes the first observer to this subject and /// starts replaying/relaying signals. All future /// observers receive an InvalidOperationException. /// </summary> /// <param name="observer">The observer to subscribe with.</param> public void Subscribe(ISignalObserver <T> observer) { ValidationHelper.RequireNonNullRef(observer, nameof(observer)); if (Interlocked.CompareExchange(ref once, 1, 0) == 0) { var inner = new MonocastDisposable(observer, this); observer.OnSubscribe(inner); if (Interlocked.CompareExchange(ref this.observer, inner, null) == null) { if (inner.IsDisposed()) { this.observer = null; } else { Drain(); } } } else { DisposableHelper.Error(observer, new InvalidOperationException("MonocastSubject allows at most one observer")); } }
public void Subscribe(ISignalObserver <T> observer) { var parent = new RepeatPredicteObserver(observer, source, predicate); observer.OnSubscribe(parent); parent.Next(); }
public void Subscribe(ISignalObserver <T> observer) { ValidationHelper.RequireNonNull(observer, nameof(observer)); var errorSignals = new PublishSubject <Exception>(); var redo = default(IObservableSource <U>); try { redo = ValidationHelper.RequireNonNullRef(handler(errorSignals), "The handler returned a null IObservableSource"); } catch (Exception ex) { DisposableHelper.Error(observer, ex); return; } var parent = new MainObserver(observer, source, new SerializedSignalObserver <Exception>(errorSignals)); observer.OnSubscribe(parent); redo.Subscribe(parent.handlerObserver); parent.HandlerNext(); }
public void Subscribe(ISignalObserver <T> observer) { var connectionDisposable = default(SingleAssignmentDisposable); var taskDisposable = default(IDisposable); lock (this) { var t = task; if (t != null) { taskDisposable = t; task = null; } if (++count == minObservers) { connectionDisposable = new SingleAssignmentDisposable(); connection = connectionDisposable; } } if (taskDisposable != null) { taskDisposable.Dispose(); } source.Subscribe(new RefCountObserver(observer, this)); if (connectionDisposable != null) { source.Connect(d => connectionDisposable.Disposable = d); } }
public void Subscribe(ISignalObserver <T> observer) { var parent = new ArrayDisposable(observer, array); observer.OnSubscribe(parent); parent.Run(); }
public BufferSkipObserver(ISignalObserver <B> downstream, Func <B> bufferSupplier, int size, int skip) { this.downstream = downstream; this.bufferSupplier = bufferSupplier; this.size = size; this.skip = skip; }
public void Subscribe(ISignalObserver <T> observer) { var parent = new FromFuncDisposable(observer); observer.OnSubscribe(parent); if (parent.IsDisposed()) { return; } var v = default(T); try { v = supplier(); } catch (Exception ex) { if (!parent.IsDisposed()) { parent.Error(ex); } return; } parent.Complete(v); }
internal static void Emit <T>(this ISignalObserver <T> subject, params T[] items) { foreach (var t in items) { subject.OnNext(t); } }
public void Subscribe(ISignalObserver <T> observer) { if (serialize) { var parent = new CreateDisposableSerializedEmitter(observer); observer.OnSubscribe(parent); try { onSubscribe(parent); } catch (Exception ex) { parent.OnError(ex); } } else { var parent = new CreateDisposableEmitter(observer); observer.OnSubscribe(parent); try { onSubscribe(parent); } catch (Exception ex) { parent.OnError(ex); } } }
public void Subscribe(ISignalObserver <T> observer) { var parent = new FromActionDisposable(observer); observer.OnSubscribe(parent); if (parent.IsDisposed()) { return; } try { action(); } catch (Exception ex) { if (!parent.IsDisposed()) { parent.Error(ex); } return; } parent.Complete(); }
public BufferBoundaryObserver(ISignalObserver <B> downstream, Func <B> bufferSupplier) { this.downstream = downstream; this.bufferSupplier = bufferSupplier; this.boundary = new BoundaryObserver(this); this.queue = new ConcurrentQueue <(T item, int state)>(); }
public void Subscribe(ISignalObserver <T> observer) { var parent = new JustDisposable(observer, item); observer.OnSubscribe(parent); parent.Run(); }
public void Subscribe(ISignalObserver <int> observer) { var parent = new RangeDisposable(observer, start, end); observer.OnSubscribe(parent); parent.Run(); }
public void Subscribe(ISignalObserver <T> observer) { var parent = new ConcatWithObserver(observer, other); observer.OnSubscribe(parent); parent.Subscribe(source); }
public TakeLastTimedObserver(ISignalObserver <T> downstream, TimeSpan timespan, IStopwatch stopwatch) { this.downstream = downstream; this.timespan = timespan; this.stopwatch = stopwatch; Volatile.Write(ref queue, new Queue <(T item, TimeSpan time)>()); }
public void Subscribe(ISignalObserver <long> observer) { var parent = new IntervalDisposable(observer, start, end); observer.OnSubscribe(parent); if (initialDelay == period) { var d = scheduler.SchedulePeriodic(parent, period, t => { t.Run(); }); parent.SetTask(d); } else { var d = scheduler.Schedule((parent, period), initialDelay, (sch, state) => { state.parent.Run(); return(sch.SchedulePeriodic(state.parent, state.period, t => { t.Run(); })); }); parent.SetTask(d); } }
public void Subscribe(ISignalObserver <T> observer) { var parent = new RetryPredicteObserver(observer, source, times); observer.OnSubscribe(parent); parent.Next(); }
internal ConcatMapEagerObserver(ISignalObserver <R> downstream, Func <T, IObservableSource <R> > mapper, int capacityHint) : base(downstream) { this.mapper = mapper; this.capacityHint = capacityHint; this.observers = new SpscLinkedArrayQueue <InnerSignalObserver <R> >(capacityHint); }
public IntervalDisposable(ISignalObserver <long> downstream, long index, long end) { this.downstream = downstream; this.index = index; this.fusedReady = index; this.end = end; }
/// <summary> /// Subscribes the observer to this subject and /// relays the live items or replays the terminal /// event to it. /// </summary> /// <param name="observer">The observer to dispatch signals to.</param> public void Subscribe(ISignalObserver <T> observer) { ValidationHelper.RequireNonNullRef(observer, nameof(observer)); var parent = new PublishDisposable(observer, this); observer.OnSubscribe(parent); if (Add(parent)) { if (parent.IsDisposed()) { Remove(parent); } } else { var ex = error; if (ex != ExceptionHelper.TERMINATED) { parent.OnError(ex); } else { parent.OnCompleted(); } } }
public void Subscribe(ISignalObserver <T> observer) { if (maxConcurrency == int.MaxValue) { var parent = new MergeMaxCoordinator(observer, delayErrors); observer.OnSubscribe(parent); foreach (var source in sources) { if (source == null) { parent.Error(new NullReferenceException()); return; } if (!parent.SubscribeTo(source)) { return; } } parent.SetDone(); } else { var parent = new MergeLimitedCoordinator(observer, delayErrors, maxConcurrency, sources); observer.OnSubscribe(parent); parent.Drain(); } }
public TimeoutObserver(ISignalObserver <T> downstream, TimeSpan timeout, IScheduler scheduler, IObservableSource <T> fallback) { this.downstream = downstream; this.timeout = timeout; this.scheduler = scheduler; this.fallback = fallback; }
public ConcatMapMainObserver(ISignalObserver<R> downstream, Func<T, IObservableSource<R>> mapper, bool delayErrors, int capacityHint) { this.downstream = downstream; this.mapper = mapper; this.delayErrors = delayErrors; this.capacityHint = capacityHint; this.inner = new InnerObserver(downstream, this); }
public void Subscribe(ISignalObserver <T> observer) { var parent = new FromObserver(observer); observer.OnSubscribe(parent); parent.OnSubscribe(source.Subscribe(parent)); }
public GroupByObserver(ISignalObserver <IGroupedObservableSource <K, V> > downstream, Func <T, K> keySelector, Func <T, V> valueSelector, IEqualityComparer <K> keyComparer) { this.downstream = downstream; this.keySelector = keySelector; this.valueSelector = valueSelector; this.groups = new ConcurrentDictionary <K, Group>(keyComparer); Volatile.Write(ref active, 1); }
public ObserveOnObserver(ISignalObserver <T> downstream, IScheduler scheduler, bool delayError, int capacityHint, bool fair) { this.downstream = downstream; this.scheduler = scheduler; this.delayError = delayError; this.capacityHint = capacityHint; this.fair = fair; }
public void Subscribe(ISignalObserver <T> observer) { var parent = new SwitchIfEmptyObserver(observer, fallbacks); observer.OnSubscribe(parent); parent.Run(source); }
public BufferOverlapObserver(ISignalObserver <B> downstream, Func <B> bufferSupplier, int size, int skip) { this.downstream = downstream; this.bufferSupplier = bufferSupplier; this.size = size; this.skip = skip; this.buffers = new Queue <B>(); }
public void Subscribe(ISignalObserver <T> observer) { var parent = new MainObserver(observer, source); observer.OnSubscribe(parent); other.Subscribe(parent.other); }