Example #1
0
        public IDisposable SubscribeRaw(IObserver <TSource> observer, bool enableSafeguard)
        {
            var subscription = new SingleAssignmentDisposable();

            //
            // See AutoDetachObserver.cs for more information on the safeguarding requirement and
            // its implementation aspects.
            //
            if (enableSafeguard)
            {
                observer = SafeObserver <TSource> .Create(observer, subscription);
            }

            if (CurrentThreadScheduler.IsScheduleRequired)
            {
                var state = new State {
                    subscription = subscription, observer = observer
                };
                CurrentThreadScheduler.Instance.Schedule(state, Run);
            }
            else
            {
                subscription.Disposable = Run(observer);
            }

            return(subscription);
        }
Example #2
0
        public IDisposable SubscribeRaw(IObserver <TTarget> observer, bool enableSafeguard)
        {
            var subscription = new SubscriptionDisposable();

            //
            // See AutoDetachObserver.cs for more information on the safeguarding requirement and
            // its implementation aspects.
            //
            if (enableSafeguard)
            {
                observer = SafeObserver <TTarget> .Create(observer, subscription);
            }

            var sink = CreateSink(observer, subscription.Inner);

            subscription.Sink = sink;

            if (CurrentThreadScheduler.IsScheduleRequired)
            {
                var state = new State {
                    sink = sink, inner = subscription.Inner
                };

                CurrentThreadScheduler.Instance.Schedule(state, Run);
            }
            else
            {
                subscription.Inner.Disposable = Run(sink);
            }

            return(subscription);
        }
Example #3
0
        internal IDisposable SubscribeRaw(IObserver <TSource> observer, bool enableSafeguard)
        {
            var state = new State();

            state.observer     = observer;
            state.sink         = new SingleAssignmentDisposable();
            state.subscription = new SingleAssignmentDisposable();

            var d = new CompositeDisposable(2)
            {
                state.sink, state.subscription
            };

            //
            // See AutoDetachObserver.cs for more information on the safeguarding requirement and
            // its implementation aspects.
            //
            if (enableSafeguard)
            {
                state.observer = SafeObserver <TSource> .Create(state.observer, d);
            }

            state.subscription.Disposable = Run(state.observer, state.subscription, state.Assign);
            return(d);
        }
Example #4
0
        public IDisposable SubscribeRaw(IObserver <TSource> observer, bool enableSafeguard)
        {
            var state = new State();

            state.observer     = observer;
            state.sink         = new SingleAssignmentDisposable();
            state.subscription = new SingleAssignmentDisposable();

            var d = new CompositeDisposable(2)
            {
                state.sink, state.subscription
            };

            //
            // See AutoDetachObserver.cs for more information on the safeguarding requirement and
            // its implementation aspects.
            //
            if (enableSafeguard)
            {
                state.observer = SafeObserver <TSource> .Create(state.observer, d);
            }

            if (CurrentThreadScheduler.IsScheduleRequired)
            {
                CurrentThreadScheduler.Instance.Schedule(state, Run);
            }
            else
            {
                state.subscription.Disposable = this.Run(state.observer, state.subscription, state.Assign);
            }

            return(d);
        }
Example #5
0
        public IDisposable SubscribeRaw(IObserver <TTarget> observer, bool enableSafeguard)
        {
            SingleAssignmentDisposable subscription = null;

            //
            // See AutoDetachObserver.cs for more information on the safeguarding requirement and
            // its implementation aspects.
            //
            if (enableSafeguard)
            {
                subscription = new SingleAssignmentDisposable();
                observer     = SafeObserver <TTarget> .Create(observer, subscription);
            }

            var sink = CreateSink(observer);

            if (subscription != null)
            {
                subscription.Disposable = sink;
            }

            if (CurrentThreadScheduler.IsScheduleRequired)
            {
                CurrentThreadScheduler.Instance.ScheduleAction(
                    (@this: this, sink),
                    tuple => [email protected](tuple.sink));
            }
            else
            {
                Run(sink);
            }

            return((IDisposable)subscription ?? sink);
        }