DotNext by Roman Sakno

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

 AtomicReference<T>

public struct AtomicReference<T> : IEquatable<T>, ISerializable
Provides container with atomic operations for the reference type.
public T Value { get; set; }

Provides volatile access to the reference value.

public AtomicReference(T value)

Initializes a new container with atomic operations for the reference type.

public T AccumulateAndGet(T x, Func<T, T, T> 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 T AccumulateAndGet(T 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(T expected, T update)

Compares two values for equality and, if they are equal, replaces the stored value.

public T CompareExchange(T expected, T update)

Compares two values for equality and, if they are equal, replaces the stored value.

public bool Equals(T other)

Checks whether the stored value is equal to the given value.

public T GetAndAccumulate(T x, Func<T, T, T> 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 T GetAndAccumulate(T 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 T GetAndSet(T update)

Modifies value of the container atomically.

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

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

public T GetAndUpdate(ref ValueFunc updater)

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

public T SetAndGet(T update)

Modifies value of the container atomically.

public T SetIfNull<G>() where G : T

Modifies stored value if it is null.

public T SetIfNull(Func<T> supplier)

Modifies stored value if it is null.

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

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

public T UpdateAndGet(ref ValueFunc updater)

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