DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.12.3" />

 AtomicBoolean

public struct AtomicBoolean : IEquatable<bool>
Represents atomic boolean.
public bool Value { get; set; }

Gets or sets boolean value in volatile manner.

public AtomicBoolean(bool value)

Initializes a new atomic boolean container with initial value.

public bool AccumulateAndGet(bool x, Func<bool, bool, bool> accumulator)

Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.

public bool AccumulateAndGet(bool x, method accumulator)

public bool CompareAndSet(bool expected, bool update)

Atomically sets referenced value to the given updated value if the current value == the expected value.

public bool CompareExchange(bool update, bool expected)

Atomically sets referenced value to the given updated value if the current value == the expected value.

public bool Equals(bool other)

Determines whether stored value is equal to value passed as argument.

public bool FalseToTrue()

Atomically sets true value if the current value is false.

public bool GetAndAccumulate(bool x, Func<bool, bool, bool> accumulator)

Atomically updates the current value with the results of applying the given function to the current and given values, returning the original value.

public bool GetAndAccumulate(bool x, method accumulator)

public bool GetAndNegate()

Negates currently stored value atomically.

public bool GetAndSet(bool update)

Modifies the current value atomically.

public bool GetAndUpdate(Func<bool, bool> updater)

Atomically updates the stored value with the results of applying the given function, returning the original value.

public bool GetAndUpdate(method updater)

public bool NegateAndGet()

Negates currently stored value atomically.

public bool SetAndGet(bool update)

Modifies the current value atomically.

public bool TrueToFalse()

Atomically sets false value if the current value is true.

public bool UpdateAndGet(Func<bool, bool> updater)

Atomically updates the stored value with the results of applying the given function, returning the updated value.

public bool UpdateAndGet(method updater)