Example #1
0
        private IDisposable Subscribe(IStreamObserver <TKey, TSource> observer, int index)
        {
            IDisposable child;

            lock (this.subscriptionLock)
            {
                if (this.toSubscribe.Add(index))
                {
                    child = new ChildDisposable(this.connectableStream.Subscribe(observer), this.crew, index);
                }
                else
                {
                    throw new InvalidOperationException("Cannot subscribe to the same child streamable more than once.");
                }

                if (this.toSubscribe.Count == this.outputCount)
                {
                    this.crew.SetListDisposable(this.connectableStream.Connect());
                    this.crew = new DisposableManager(this.outputCount);
                    this.connectableStream = new ConnectableStreamable <TKey, TSource>(this.source);
                    this.toSubscribe.Clear();
                }
            }
            return(child);
        }
Example #2
0
        public override IDisposable Subscribe(IStreamObserver <TKey, TResult> observer)
        {
            var         connectableInput = new ConnectableStreamable <TKey, TSource>(this.source);
            var         output           = this.selector(connectableInput);
            IDisposable d1 = output.Subscribe(observer);
            IDisposable d2 = connectableInput.Connect();

            return(Utility.CreateDisposable(d1, d2));
        }
Example #3
0
        private NWayMulticast(IStreamable <TKey, TSource> source, int outputCount)
        {
            Contract.Requires(source != null);
            Contract.Requires(outputCount > 0);

            this.source            = source;
            this.connectableStream = new ConnectableStreamable <TKey, TSource>(source);
            this.outputCount       = outputCount;
            this.crew = new DisposableManager(outputCount);
        }
Example #4
0
            public DependentStreamable(
                ConnectableStreamable <TKeyInner, TSourceInner> source,
                NWayMulticast <TKeyInner, TSourceInner> leader,
                int index)
                : base(source.Properties)
            {
                Contract.Requires(source != null);
                Contract.Requires(leader != null);
                Contract.Requires(index >= 0);

                this.leader = leader;
                this.index  = index;
            }