コード例 #1
0
ファイル: Producer.cs プロジェクト: akarnokd/Rx.NET
        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);
        }
コード例 #2
0
ファイル: Producer.cs プロジェクト: TonyDoumanis/Rx
        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);
        }
コード例 #3
0
ファイル: Producer.cs プロジェクト: eromanowski/reactive
        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);
        }
コード例 #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);
        }
コード例 #5
0
ファイル: Producer.cs プロジェクト: ibebbs/reactive
        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),