Exemple #1
0
 /// <summary>
 /// Map a position over a buffer and this indicator owns the counter for reclamation.
 /// </summary>
 /// <param name="buffer">          containing the counter. </param>
 /// <param name="counterId">       identifier of the counter. </param>
 /// <param name="countersManager"> to be used for freeing the counter when this is closed. </param>
 public UnsafeBufferPosition(UnsafeBuffer buffer, int counterId, CountersManager countersManager)
 {
     _buffer          = buffer;
     _counterId       = counterId;
     _countersManager = countersManager;
     _offset          = CountersReader.CounterOffset(counterId);
 }
 internal AtomicCounter(IAtomicBuffer buffer, int counterId, CountersManager countersManager)
 {
     _buffer          = buffer;
     _counterId       = counterId;
     _countersManager = countersManager;
     _offset          = CountersReader.CounterOffset(counterId);
     buffer.PutLong(_offset, 0);
 }
Exemple #3
0
 /// <summary>
 /// Map a counter over a buffer. This version will free the counter on close.
 /// </summary>
 /// <param name="buffer">          containing the counter. </param>
 /// <param name="counterId">       identifier for the counter. </param>
 /// <param name="countersManager"> to be called to free the counter on close. </param>
 public AtomicCounter(IAtomicBuffer buffer, int counterId, CountersManager countersManager)
 {
     _buffer          = buffer;
     Id               = counterId;
     _countersManager = countersManager;
     _offset          = CountersReader.CounterOffset(counterId);
     buffer.BoundsCheck(_offset, BitUtil.SIZE_OF_LONG);
 }
Exemple #4
0
        public void Setup()
        {
            _consumer = A.Fake<IntObjConsumer<string>>();
            _metaData = A.Fake<CountersReader.MetaData>();

            _labelsBuffer = new UnsafeBuffer(new byte[NumberOfCounters*CountersReader.METADATA_LENGTH]);
            _counterBuffer = new UnsafeBuffer(new byte[NumberOfCounters*CountersReader.COUNTER_LENGTH]);

            _manager = new CountersManager(_labelsBuffer, _counterBuffer);
            _otherManager = new CountersManager(_labelsBuffer, _counterBuffer);
        }