Exemplo n.º 1
0
        public void Can_be_assigned()
        {
            _num.SetValue(10L);
            PaddedAtomicLong y = _num;

            y.GetValue().Should().Be(10L);
        }
Exemplo n.º 2
0
        public void drain_onRead(ConcurrentLinkedDictionary <int, int> map)
        {
            PaddedAtomicReference <ConcurrentLinkedDictionary <int, int> .Node>[] buffer = map.readBuffers[ConcurrentLinkedDictionary <int, int> .readBufferIndex()];
            PaddedAtomicLong writeCounter = map.readBufferWriteCount[ConcurrentLinkedDictionary <int, int> .readBufferIndex()];

            for (int i = 0; i < ConcurrentLinkedDictionary <int, int> .READ_BUFFER_THRESHOLD; i++)
            {
                var x = map[1];
            }

            int pending = 0;

            foreach (PaddedAtomicReference <ConcurrentLinkedDictionary <int, int> .Node> slot in buffer)
            {
                if (slot.GetValue() != null)
                {
                    pending++;
                }
            }
            Assert.That(pending, Is.EqualTo(ConcurrentLinkedDictionary <int, int> .READ_BUFFER_THRESHOLD));
            Assert.That((int)writeCounter.GetValue(), Is.EqualTo(pending));

            var k = map [1];

            Assert.That(map.readBufferReadCount[ConcurrentLinkedDictionary <int, int> .readBufferIndex()], Is.EqualTo(writeCounter.GetValue()));
            for (int i = 0; i < map.readBuffers.Length; i++)
            {
                Assert.That(map.readBuffers[ConcurrentLinkedDictionary <int, int> .readBufferIndex()][i].GetValue(), Is.Null);
            }
        }
        public void PaddedAtomicLong_CanBeAssigned()
        {
            this.num.SetValue(10L);
            PaddedAtomicLong y = num;

            y.GetValue().Should().Be(10L);
        }
 public override void Setup()
 {
     _atomicLong           = new AtomicLong();
     _paddedAtomicLong     = new PaddedAtomicLong();
     _stripedLongAdder     = new StripedLongAdder();
     _threadLocalLongAdder = new ThreadLocalLongAdder();
 }
Exemplo n.º 5
0
        public void exceedsMaximumBufferSize_onRead(ConcurrentLinkedDictionary <int, int> map)
        {
            PaddedAtomicLong drainCounter = map.readBufferDrainAtWriteCount[ConcurrentLinkedDictionary <int, int> .readBufferIndex()];

            map.readBufferWriteCount[ConcurrentLinkedDictionary <int, int> .readBufferIndex()].SetValue(ConcurrentLinkedDictionary <int, int> .READ_BUFFER_THRESHOLD - 1);

            map.afterRead(null);
            Assert.That(drainCounter.GetValue(), Is.EqualTo(0L));

            map.afterRead(null);
            Assert.That(drainCounter.GetValue(), Is.EqualTo(ConcurrentLinkedDictionary <int, int> .READ_BUFFER_THRESHOLD + 1L));
        }
Exemplo n.º 6
0
        public void updateRecency_onGetQuietly(ConcurrentLinkedDictionary <int, int> map)
        {
            PaddedAtomicLong drainCounter = map.readBufferDrainAtWriteCount[ConcurrentLinkedDictionary <int, int> .readBufferIndex()];

            var  first   = map.evictionDeque.Peek();
            long drained = drainCounter.GetValue();

            map.GetQuietly(first.Key);
            map.DrainBuffers();

            Assert.That(map.evictionDeque.Peek(), Is.SameAs(first));
            Assert.That(drainCounter.GetValue(), Is.EqualTo(drained));
        }
 public override void Setup()
 {
     _num = new PaddedAtomicLong(0);
 }
 public Cell(long x)
 {
     this.Value = new PaddedAtomicLong(x);
 }
 public void Setup()
 {
     _num = new PaddedAtomicLong();
 }