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

            myRunnable.Reset(latch, expectedCount);
            Task.Factory.StartNew(() => myRunnable.Run());
            Stopwatch watch = Stopwatch.StartNew();

            ISequenced sequencer = this.sequencer;

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

            latch.Wait();

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

            waitForEventProcessorSequence(expectedCount);

            return(opsPerSecond);
        }
 public void Run()
 {
     while (_running)
     {
         var sequence = _ringBuffer.Next();
         _ringBuffer.Publish(sequence);
         _publicationCount++;
     }
 }
Exemple #3
0
    public Task Start()
    {
        return(Task.Factory.StartNew(Run, TaskCreationOptions.LongRunning));

        void Run()
        {
            while (_running)
            {
                var sequence = _ringBuffer.Next();
                _ringBuffer.Publish(sequence);
                _publicationCount++;
            }
        }
    }