OpenStory.Common.AtomicInteger.CompareExchange C# (CSharp) Method

CompareExchange() public method

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.
return int
        public int CompareExchange(int comparand, int newValue)
        {
            return Interlocked.CompareExchange(ref this.value, newValue, comparand);
        }

Usage Example

Exemplo n.º 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);
        }
All Usage Examples Of OpenStory.Common.AtomicInteger::CompareExchange