コード例 #1
0
        public static void AtomicFloatTest()
        {
            float i = 10F;

            Equal(11F, i.IncrementAndGet());
            Equal(10F, i.DecrementAndGet());
            i = 20F;
            True(i.CompareAndSet(20F, 30F));
            Equal(30F, i);
            False(i.CompareAndSet(20F, 50F));
            Equal(30F, i);
            Equal(80F, i.Add(50F));
            Equal(80F, i);
            Equal(80F, i.GetAndAccumulate(10F, static (x, y) => x + y));
            Equal(90F, i);
            Equal(10F, i.AccumulateAndGet(80F, static (x, y) => x - y));
            Equal(10F, i);
            Equal(10F, i.GetAndSet(25F));
            Equal(25F, i);
            Equal(42F, i.UpdateAndGet(static current => 42F));