public ConcurrentRingBufferWriter(int bufferSize, IWaitStrategy waitStrategy)
     : base(waitStrategy)
 {
     _bufferSize = bufferSize;
     _nextFree = new Sequence();
     _lastFree = new Sequence(bufferSize - 1);
 }
Пример #2
0
 public long WaitFor(long position, Sequence sequence)
 {
     long current;
     while ((current = sequence.VolatileGet()) < position)
     {
         lock (_sync)
         {
             _waitingQueueSize++;
             current = sequence.VolatileGet();
             if (position <= current)
             {
                 _waitingQueueSize--;
                 return current;
             }
             Monitor.Wait(_sync);
             _waitingQueueSize--;
         }
     }
     return current;
 }