Пример #1
0
 private IDisposable Run(ISchedulerLongRunning scheduler)
 {
     if (_parent._repeatCount == null)
     {
         return(scheduler.ScheduleLongRunning(LoopInf));
     }
     else
     {
         return(scheduler.ScheduleLongRunning(_parent._repeatCount.Value, Loop));
     }
 }
Пример #2
0
 public void Run()
 {
     if (_prepends == null)
     {
         SetUpstream(_source.SubscribeSafe(this));
     }
     else
     {
         var disposable = _scheduler.ScheduleLongRunning(this, (@this, cancel) => @this.PrependValues(cancel));
         Disposable.TrySetSingle(ref _schedulerDisposable, disposable);
     }
 }
Пример #3
0
 private Notification <TSource> _completion; // completion notification
 public LoopSubscription(IObservable <TSource> source, int maxQueueSize, ISchedulerLongRunning scheduler, IObserver <TSource> observer)
 {
     _observer = observer;
     _queue    = Queue.Create(maxQueueSize);
     scheduler.ScheduleLongRunning(_ => Loop());
     _subscription.Disposable = source.Subscribe(
         OnNext,
         error => OnCompletion(Notification.CreateOnError <TSource>(error)),
         () => OnCompletion(Notification.CreateOnCompleted <TSource>()));
 }
Пример #4
0
        /// <summary>
        /// Schedules an action to be executed.
        /// </summary>
        /// <param name="scheduler">Scheduler to execute the action on.</param>
        /// <param name="action">Action to execute.</param>
        /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> or <paramref name="action"/> is null.</exception>
        public static IDisposable ScheduleLongRunning(this ISchedulerLongRunning scheduler, Action <ICancelable> action)
        {
            if (scheduler == null)
            {
                throw new ArgumentNullException(nameof(scheduler));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(scheduler.ScheduleLongRunning(action, (a, c) => a(c)));
        }
Пример #5
0
 public IDisposable ScheduleLongRunning <TState>(TState state, Action <TState, ICancelable> action)
 {
     return(_scheduler.ScheduleLongRunning(state, (state_, cancel) =>
     {
         try
         {
             action(state_, cancel);
         }
         catch (TException exception) when(_handler(exception))
         {
         }
     }));
 }
Пример #6
0
            public IDisposable ScheduleLongRunning <TState>(TState state, Action <TState, ICancelable> action)
            {
                // Note that avoiding closure allocation here would introduce infinite generic recursion over the TState argument

                return(_scheduler.ScheduleLongRunning(
                           state,
                           (state1, cancel) =>
                {
                    try
                    {
                        action(state1, cancel);
                    }
                    catch (TException exception) when(_handler(exception))
                    {
                    }
                }));
            }
Пример #7
0
        private void EnsureDispatcher()
        {
            if (_dispatcherJob == null)
            {
                lock (_dispatcherInitGate)
                {
                    if (_dispatcherJob == null)
                    {
                        _dispatcherJob = _longRunning.ScheduleLongRunning(Dispatch);

                        _disposable.Disposable = StableCompositeDisposable.Create
                                                 (
                            _dispatcherJob,
                            _dispatcherEventRelease
                                                 );
                    }
                }
            }
        }
Пример #8
0
        private void Schedule()
        {
            // Schedule the suspending drain once
            if (Volatile.Read(ref _runDrainOnce) == 0 &&
                Interlocked.CompareExchange(ref _runDrainOnce, 1, 0) == 0)
            {
                Disposable.SetSingle(ref _drainTask, _scheduler.ScheduleLongRunning(this, DrainLongRunning));
            }

            // Indicate more work is to be done by the drain loop
            if (Interlocked.Increment(ref _wip) == 1L)
            {
                // resume the drain loop waiting on the guard
                lock (_suspendGuard)
                {
                    Monitor.Pulse(_suspendGuard);
                }
            }
        }
Пример #9
0
        private void EnsureDispatcher()
        {
            if (_dispatcherJob == null)
            {
                lock (_dispatcherInitGate)
                {
                    if (_dispatcherJob == null)
                    {
                        _dispatcherJob = _longRunning.ScheduleLongRunning(Dispatch);

                        _disposable.Disposable = new CompositeDisposable(2)
                        {
                            _dispatcherJob,
                            Disposable.Create(() => _dispatcherEvent.Release())
                        };
                    }
                }
            }
        }
Пример #10
0
 public void Run(ISchedulerLongRunning scheduler)
 {
     SetUpstream(scheduler.ScheduleLongRunning(this, static (@this, cancel) => @this.Loop(cancel)));
 }
Пример #11
0
 public void Run(ISchedulerLongRunning longRunning)
 {
     SetUpstream(longRunning.ScheduleLongRunning(this, static (@this, c) => @this.LoopInf(c)));
 }
 public LongRunningEmitter(IObserver <TSource> observer, ISchedulerLongRunning scheduler)
 {
     _observer = observer;
     scheduler.ScheduleLongRunning(_ => Loop());
 }
Пример #13
0
 public void Run(ISchedulerLongRunning longRunning)
 {
     SetUpstream(longRunning.ScheduleLongRunning(this, (@this, cancel) => @this.Loop(cancel)));
 }