Esempio n. 1
0
            public IDisposable Run()
            {
                cancelationToken = new BooleanDisposable();
                var _sourceSubscription = new SingleAssignmentDisposable();

                sourceSubscription             = _sourceSubscription;
                _sourceSubscription.Disposable = parent.source.Subscribe(this);
                return(StableCompositeDisposable.Create(cancelationToken, sourceSubscription));
            }
Esempio n. 2
0
 public IDisposable Start(IObservable <IObservable <T> > upstream)
 {
     subscription.Disposable =
         StableCompositeDisposable.Create(
             innerSubscriptionContainer,
             upstream.Subscribe(this)
             );
     return(subscription);
 }
Esempio n. 3
0
                public IDisposable Run(Time parent)
                {
                    _gate = new object();

                    var t = parent._scheduler.Schedule(parent._duration, Tick);
                    var d = parent._source.SubscribeSafe(this);

                    return(StableCompositeDisposable.Create(t, d));
                }
Esempio n. 4
0
 public IDisposable Run()
 {
     return(StableCompositeDisposable.Create(parent.source.Subscribe(this), Disposable.Create(() => {
         if (!isCompletedCall)
         {
             parent.onCancel();
         }
     })));
 }
Esempio n. 5
0
            public IDisposable Run()
            {
                sourceSubscription = new SingleAssignmentDisposable();

                timerSubscription             = parent.scheduler.Schedule(parent.dueTimeDT.Value, OnNext);
                sourceSubscription.Disposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(timerSubscription, sourceSubscription));
            }
Esempio n. 6
0
            public IDisposable Run()
            {
                tick       = new ThrottleFirstFrameTick(this);
                cancelable = new SerialDisposable();

                var subscription = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(cancelable, subscription));
            }
Esempio n. 7
0
            public IDisposable Run()
            {
                var l             = parent.left.Subscribe(new LeftObserver(this));
                var rSubscription = new SingleAssignmentDisposable();

                rSubscription.Disposable = parent.right.Subscribe(new RightObserver(this, rSubscription));

                return(StableCompositeDisposable.Create(l, rSubscription));
            }
Esempio n. 8
0
                public IDisposable Run(TimeHopping parent)
                {
                    _list = new List <TSource>();

                    var d = parent._scheduler.SchedulePeriodic(parent._timeSpan, Tick);
                    var s = parent._source.SubscribeSafe(this);

                    return(StableCompositeDisposable.Create(d, s));
                }
Esempio n. 9
0
                public IDisposable Run(Boundaries parent)
                {
                    _buffer = new List <TSource>();

                    var sourceSubscription     = parent._source.SubscribeSafe(this);
                    var boundariesSubscription = parent._bufferBoundaries.SubscribeSafe(new BufferClosingObserver(this));

                    return(StableCompositeDisposable.Create(sourceSubscription, boundariesSubscription));
                }
Esempio n. 10
0
            public IDisposable Run()
            {
                _subscription = new SingleAssignmentDisposable();
                _loop         = new SingleAssignmentDisposable();

                _subscription.Disposable = _parent._source.SubscribeSafe(this);

                return(StableCompositeDisposable.Create(_subscription, _loop));
            }
Esempio n. 11
0
        protected override IDisposable Run(IObserver <TSource> observer, IDisposable cancel, Action <IDisposable> setSink)
        {
            var d = StableCompositeDisposable.Create(_refCount.GetDisposable(), cancel);

            var sink = new _(observer, d);

            setSink(sink);
            return(_source.SubscribeSafe(sink));
        }
Esempio n. 12
0
            public IDisposable Run()
            {
                sourceSubscription            = new SingleAssignmentDisposable();
                timerSubscription             = new SerialDisposable();
                timerSubscription.Disposable  = RunTimer(objectId);
                sourceSubscription.Disposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(timerSubscription, sourceSubscription));
            }
            public IDisposable Run()
            {
                this.cancelationToken = new BooleanDisposable();
                SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable();

                this.sourceSubscription = singleAssignmentDisposable;
                singleAssignmentDisposable.Disposable = this.parent.source.Subscribe(this);
                return(StableCompositeDisposable.Create(this.cancelationToken, this.sourceSubscription));
            }
Esempio n. 14
0
        /// <summary>
        /// Subscribes an observer to the ListObservable which will be notified upon completion.
        /// </summary>
        /// <param name="observer">The observer to send completion or error messages to.</param>
        /// <returns>The disposable resource that can be used to unsubscribe.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="observer"/> is <c>null</c>.</exception>
        public IDisposable Subscribe(IObserver <object> observer)
        {
            if (observer == null)
            {
                throw new ArgumentNullException(nameof(observer));
            }

            return(StableCompositeDisposable.Create(subscription, subject.Subscribe(observer)));
        }
Esempio n. 15
0
 IObservable <bool> IsDoubleDraggingAsObservable()
 {
     return(Observable.Create <bool>(observer =>
     {
         var isSeriesUntil = 0f;
         return StableCompositeDisposable.Create(
             Controller.MainButtonPressed.Select(pressed => pressed && Time.time < isSeriesUntil).DistinctUntilChanged().Subscribe(observer),
             Controller.MainButtonPressed.Where(pressed => pressed).Subscribe(_ => isSeriesUntil = Time.time + GraceSeconds));
     }));
 }
            protected override IDisposable SubscribeCore(IObserver <TResult> observer)
            {
                var cancellable = new CancellationDisposable();

                var taskObservable         = subscribeAsync(observer, cancellable.Token).ToObservable();
                var taskCompletionObserver = new TaskCompletionObserver(observer);
                var subscription           = taskObservable.Subscribe(taskCompletionObserver);

                return(StableCompositeDisposable.Create(cancellable, subscription));
            }
        public static IDisposable Subscribe <T>(this IAsyncStreamReader <T> stream, IObserver <T> observer, bool observeOnMainThread = true, IDisposable streamingResult = null)
        {
            var subscription = AsObservable(stream, observeOnMainThread).Subscribe(observer);

            if (streamingResult == null)
            {
                return(subscription);
            }
            return(StableCompositeDisposable.Create(subscription, streamingResult));
        }
Esempio n. 18
0
            public IDisposable Run()
            {
                var otherSubscription = new SingleAssignmentDisposable();
                var otherObserver     = new TakeUntilOther(this, otherSubscription);

                otherSubscription.Disposable = parent.other.Subscribe(otherObserver);
                var sourceSubscription = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(otherSubscription, sourceSubscription));
            }
Esempio n. 19
0
            public IDisposable Run()
            {
                cancelable = new SerialDisposable();
                var subscription = parent.source.Subscribe(this);

                messageQueue = new Queue<T>(10);
                MainThreadDispatcher.SendStartCoroutine(TakeCoroutine());

                return StableCompositeDisposable.Create(cancelable, subscription);
            }
Esempio n. 20
0
            public IDisposable Run()
            {
                SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable();
                TakeUntilOther             observer = new TakeUntilOther(this, singleAssignmentDisposable);

                singleAssignmentDisposable.Disposable = parent.other.Subscribe(observer);
                IDisposable disposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(singleAssignmentDisposable, disposable));
            }
Esempio n. 21
0
            public IDisposable Run()
            {
                sourceSubscription            = new SingleAssignmentDisposable();
                sourceSubscription.Disposable = parent.source.Subscribe(this);

                var scheduling = this.parent.intervalSource
                                 .Subscribe(new SampleTick(this));

                return(StableCompositeDisposable.Create(sourceSubscription, scheduling));
            }
Esempio n. 22
0
                public IDisposable Run(IObservable <TSource> source)
                {
                    _buffer = new List <TSource>();

                    var groupDisposable = StableCompositeDisposable.Create(_bufferClosingSubscription, source.SubscribeSafe(this));

                    _bufferGate.Wait(CreateBufferClose);

                    return(groupDisposable);
                }
Esempio n. 23
0
            public IDisposable Run()
            {
                _gate = new object();
                _list = new List <TSource>();

                var d = _parent._scheduler.SchedulePeriodic(_parent._timeSpan, Tick);
                var s = _parent._source.SubscribeSafe(this);

                return(StableCompositeDisposable.Create(d, s));
            }
 public IDisposable Run()
 {
     return(StableCompositeDisposable.Create(this.parent.source.Subscribe(this), Disposable.Create(delegate
     {
         if (!this.isCompletedCall)
         {
             this.parent.onCancel();
         }
     })));
 }
Esempio n. 25
0
            public IDisposable Run()
            {
                sourceSubscription            = new SingleAssignmentDisposable();
                sourceSubscription.Disposable = parent.source.Subscribe(this);

                IDisposable scheduling = UnityObservable.IntervalFrame(parent.frameCount, parent.frameCountType)
                                         .Subscribe(new SampleFrameTick(this));

                return(StableCompositeDisposable.Create(sourceSubscription, scheduling));
            }
Esempio n. 26
0
            public IDisposable Run()
            {
                list    = new List <T>();
                timerId = 0L;
                timerD  = new SerialDisposable();
                CreateTimer();
                IDisposable disposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(disposable, timerD));
            }
Esempio n. 27
0
        /// <summary>
        /// Schedules a periodic piece of work by running a platform-specific timer to create tasks periodically.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">Initial state passed to the action upon the first iteration.</param>
        /// <param name="period">Period for running the work periodically.</param>
        /// <param name="action">Action to be executed, potentially updating the state.</param>
        /// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="period"/> is less than TimeSpan.Zero.</exception>
        public IDisposable SchedulePeriodic <TState>(TState state, TimeSpan period, Func <TState, TState> action)
        {
            if (period < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(period));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

#if !NO_TASK_DELAY
            var cancel = new CancellationDisposable();

            var state1 = state;
            var gate   = new AsyncLock();

            var moveNext = default(Action);
            moveNext = () =>
            {
                TaskHelpers.Delay(period, cancel.Token).ContinueWith(
                    _ =>
                {
                    moveNext();

                    gate.Wait(() =>
                    {
                        state1 = action(state1);
                    });
                },
                    CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, taskFactory.Scheduler
                    );
            };

            moveNext();

            return(StableCompositeDisposable.Create(cancel, gate));
#else
            var state1 = state;
            var gate   = new AsyncLock();

            var timer = ConcurrencyAbstractionLayer.Current.StartPeriodicTimer(() =>
            {
                taskFactory.StartNew(() =>
                {
                    gate.Wait(() =>
                    {
                        state1 = action(state1);
                    });
                });
            }, period);

            return(StableCompositeDisposable.Create(timer, gate));
#endif
        }
Esempio n. 28
0
            public IDisposable Run()
            {
                list = new List <T>();

                var timerSubscription = Observable.Interval(parent.timeSpan, parent.scheduler)
                                        .Subscribe(new Buffer(this));

                var sourceSubscription = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(timerSubscription, sourceSubscription));
            }
        /// <summary>
        /// Schedules a periodic piece of work by running a platform-specific timer to create tasks periodically.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">Initial state passed to the action upon the first iteration.</param>
        /// <param name="period">Period for running the work periodically.</param>
        /// <param name="action">Action to be executed, potentially updating the state.</param>
        /// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="period"/> is less than <see cref="TimeSpan.Zero"/>.</exception>
        public IDisposable SchedulePeriodic <TState>(TState state, TimeSpan period, Func <TState, TState> action)
        {
            if (period < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(period));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var cancel = new CancellationDisposable();

            var state1 = state;
            var gate   = new AsyncLock();

            var moveNext = default(Action);

            moveNext = () =>
            {
                //TaskHelpers.Delay(period, cancel.Token).ContinueWith(
                //    _ =>
                //    {
                //        moveNext();

                //        gate.Wait(() =>
                //        {
                //            state1 = action(state1);
                //        });
                //    },
                //CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, taskFactory.Scheduler
                TaskHelpers.Delay(period, cancel.Token).ContinueWith(
                    t =>
                {
                    if (!t.IsCompletedSuccessfully)
                    {
                        return;
                    }

                    moveNext();

                    gate.Wait(() =>
                    {
                        state1 = action(state1);
                    });
                },
                    CancellationToken.None
                    );
            };

            moveNext();

            return(StableCompositeDisposable.Create(cancel, gate));
        }
Esempio n. 30
0
            public IDisposable Run()
            {
                this.c1 = new ZipLatestObserver <T1>(this.gate, this, 0);
                this.c2 = new ZipLatestObserver <T2>(this.gate, this, 1);
                this.c3 = new ZipLatestObserver <T3>(this.gate, this, 2);
                IDisposable disposable  = this.parent.source1.Subscribe(this.c1);
                IDisposable disposable2 = this.parent.source2.Subscribe(this.c2);
                IDisposable disposable3 = this.parent.source3.Subscribe(this.c3);

                return(StableCompositeDisposable.Create(disposable, disposable2, disposable3));
            }