Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public IDisposable SubscribeRaw(IObserver <TSource> observer, bool enableSafeguard)
        {
            IDisposable             run;
            ISafeObserver <TSource>?safeObserver = null;

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

            if (CurrentThreadScheduler.IsScheduleRequired)
            {
                var runAssignable = new SingleAssignmentDisposable();

                CurrentThreadScheduler.Instance.ScheduleAction(
                    (@this: this, runAssignable, observer),