DotNext by Roman Sakno

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

 AtomicEnum<TEnum>

public struct AtomicEnum<TEnum> : IEquatable<TEnum>, ISerializable 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, ref ValueFunc 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 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, ref ValueFunc 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 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(ref ValueFunc updater)

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

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(ref ValueFunc updater)

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