DotNext by .NET Foundation and Contributors

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

 AtomicEnum<TEnum>

public struct AtomicEnum<TEnum> : IEquatable<TEnum> where TEnum : struct, Enum
Represents atomic enum value.
public TEnum Value { get; set; }

Gets or sets enum value in volatile manner.

public AtomicEnum(TEnum value)

Initializes a new atomic boolean container with initial value.

public TEnum AccumulateAndGet(TEnum x, Func<TEnum, TEnum, TEnum> 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 TEnum AccumulateAndGet(TEnum x, method accumulator)

public bool CompareAndSet(TEnum expected, TEnum update)

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

public TEnum CompareExchange(TEnum update, TEnum expected)

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

public bool Equals(TEnum other)

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

public TEnum GetAndAccumulate(TEnum x, Func<TEnum, TEnum, TEnum> 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 TEnum GetAndAccumulate(TEnum x, method accumulator)

public TEnum GetAndSet(TEnum update)

Modifies the current value atomically.

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

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

public TEnum GetAndUpdate(method updater)

public TEnum SetAndGet(TEnum update)

Modifies the current value atomically.

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

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

public TEnum UpdateAndGet(method updater)