コード例 #1
0
        private int NextCounterId()
        {
            if (_freeList.Count == 0)
            {
                return(++_idHighWaterMark);
            }

            var counterId = _freeList.Dequeue();

            ValuesBuffer.PutLongOrdered(CounterOffset(counterId), 0L);

            return(counterId);
        }
コード例 #2
0
ファイル: CountersManager.cs プロジェクト: valmac/Aeron.NET
        private int NextCounterId()
        {
            long nowMs = _epochClock.Time();

            for (int i = 0, size = _freeList.Count; i < size; i++)
            {
                int counterId = _freeList[i];

                long deadlineMs = MetaDataBuffer.GetLongVolatile(MetaDataOffset(counterId) + FREE_FOR_REUSE_DEADLINE_OFFSET);

                if (nowMs >= deadlineMs)
                {
                    _freeList.Remove(i);
                    ValuesBuffer.PutLongOrdered(CounterOffset(counterId), 0L);

                    return(counterId);
                }
            }

            return(++_idHighWaterMark);
        }
コード例 #3
0
ファイル: CountersManager.cs プロジェクト: valmac/Aeron.NET
 /// <summary>
 /// Set an <seealso cref="AtomicCounter"/> value based on counterId.
 /// </summary>
 /// <param name="counterId"> to be set. </param>
 /// <param name="value">     to set for the counter. </param>
 public void SetCounterValue(int counterId, long value)
 {
     ValuesBuffer.PutLongOrdered(CounterOffset(counterId), value);
 }