CompareExchange() 공개 메소드

Assigns a new value to the AtomicInteger if the current value is equal to a specified one, and returns the original value.
See Interlocked.CompareExchange(ref int,int,int) for details.
public CompareExchange ( int comparand, int newValue ) : int
comparand int The value to compare for equality with.
newValue int The value to assign if the and comparand are equal.
리턴 int
예제 #1
0
        public void CompareExchange_Should_Set_New_Value_When_Comparand_Matches()
        {
            var i = new AtomicInteger(123);

            i.CompareExchange(123, 321);

            i.Value.Should().Be(321);
        }
예제 #2
0
        public void CompareExchange_Should_Return_Current_Value_When_Comparand_Does_Not_Match()
        {
            var i = new AtomicInteger(123);

            var current = i.CompareExchange(234, 432);

            current.Should().Be(123);
        }
예제 #3
0
        public void CompareExchange_Should_Return_Old_Value_When_Comparand_Matches()
        {
            var i = new AtomicInteger(123);

            var old = i.CompareExchange(123, 321);

            old.Should().Be(123);
        }
예제 #4
0
        public void CompareExchange_Should_Not_Set_New_Value_When_Comparand_Does_Not_Match()
        {
            var i = new AtomicInteger(123);

            i.CompareExchange(234, 432);

            i.Value.Should().Be(123);
        }
        public void CompareExchange_Should_Return_Current_Value_When_Comparand_Does_Not_Match()
        {
            var i = new AtomicInteger(123);

            var current = i.CompareExchange(234, 432);

            current.Should().Be(123);
        }
        public void CompareExchange_Should_Not_Set_New_Value_When_Comparand_Does_Not_Match()
        {
            var i = new AtomicInteger(123);

            i.CompareExchange(234, 432);

            i.Value.Should().Be(123);
        }
        public void CompareExchange_Should_Return_Old_Value_When_Comparand_Matches()
        {
            var i = new AtomicInteger(123);

            var old = i.CompareExchange(123, 321);

            old.Should().Be(123);
        }
        public void CompareExchange_Should_Set_New_Value_When_Comparand_Matches()
        {
            var i = new AtomicInteger(123);

            i.CompareExchange(123, 321);

            i.Value.Should().Be(321);
        }