Akka.Util.AtomicBoolean.CompareAndSet C# (CSharp) Method

CompareAndSet() public method

If Value equals expected, then set the Value to newValue.
public CompareAndSet ( bool expected, bool newValue ) : bool
expected bool
newValue bool
return bool
        public bool CompareAndSet(bool expected, bool newValue)
        {
            var expectedInt = expected ? _trueValue : _falseValue;
            var newInt = newValue ? _trueValue : _falseValue;
            return Interlocked.CompareExchange(ref _value, newInt, expectedInt) == expectedInt;           
        }