protected override long RunDisruptorPass()
        {
            int  batchSize     = 10;
            var  latch         = new ManualResetEvent(false);
            long expectedCount = myRunnable.GetSequence.Value + (ITERATIONS * batchSize);

            myRunnable.Reset(latch, expectedCount);
            var _scheduler = new RoundRobinThreadAffinedTaskScheduler(4);

            Task.Factory.StartNew(myRunnable.Run, CancellationToken.None, TaskCreationOptions.None, _scheduler);
            var start     = Stopwatch.StartNew();
            var spinwait  = default(SpinWait);
            var sequencer = this.sequencer;

            for (long i = 0; i < ITERATIONS; i++)
            {
                long next = sequencer.Next(batchSize);
                sequencer.Publish((next - (batchSize - 1)), next);
            }

            latch.WaitOne();

            long opsPerSecond = (ITERATIONS * 1000L * batchSize) / start.ElapsedMilliseconds;

            WaitForEventProcessorSequence(expectedCount, spinwait, myRunnable);

            return(opsPerSecond);
        }
        protected override long RunDisruptorPass()
        {
            var ob = Observable.Create <long>(o =>
            {
                var cancel = new CancellationDisposable(); // internally creates a new CancellationTokenSource

                Scheduler.Default.Schedule(() =>
                {
                    for (long i = 0; i < ITERATIONS; i++)
                    {
                        //Thread.Sleep(200);  // here we do the long lasting background operation
                        if (!cancel.Token.IsCancellationRequested)    // check cancel token periodically
                        {
                            o.OnNext(i++);
                        }
                        else
                        {
                            Console.WriteLine("Aborting because cancel event was signaled!");
                            o.OnCompleted();
                            return;
                        }
                    }
                }
                                           );

                return(cancel);
            }
                                              );

            var spinwait = default(SpinWait);
            //var latch = new CountdownEvent(1);
            var latch         = new ManualResetEvent(false);
            var expectedCount = myRunnable.GetSequence.Value + ITERATIONS;

            myRunnable.Reset(latch, expectedCount);
            var _scheduler = new RoundRobinThreadAffinedTaskScheduler(4);

            //TaskScheduler.Default调度器 CPU 约在 50 % 两个繁忙,两个空闲
            //

            Task.Factory.StartNew(myRunnable.Run, CancellationToken.None, TaskCreationOptions.None, TestTaskScheduler);

            var start = Stopwatch.StartNew();

            var sequencer = this.sequencer;

            //var range = Observable.Range(0, 1000 * 1000 * 100, Scheduler.Default)
            //       .Subscribe(i => {
            //           long next = sequencer.Next();
            //           sequencer.Publish(next);
            //       });
            // var subscription = ob.Subscribe(i =>
            for (long i = 0; i < ITERATIONS; i++)
            {
                long next = sequencer.Next();
                sequencer.Publish(next);
            }
            //);

            latch.WaitOne();
            long opsPerSecond = (ITERATIONS * 1000L) / start.ElapsedMilliseconds;

            WaitForEventProcessorSequence(expectedCount, spinwait, myRunnable);

            return(opsPerSecond);
        }