DotNext by Roman Sakno

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

 AtomicReference

public static class AtomicReference
Provides atomic operations for the reference type.
public static T AccumulateAndGet<T>(ref T value, 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 static T AccumulateAndGet<T>(ref T value, 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 static T AccumulateAndGet<T>(this T[] array, long index, T x, Func<T, T, T> accumulator)

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

public static T AccumulateAndGet<T>(this T[] array, long index, T x, ref ValueFunc accumulator)

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

public static bool CompareAndSet<T>(ref T value, T expected, T update)

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

public static bool CompareAndSet<T>(this T[] array, long index, T expected, T update)

Atomically sets array element to the given updated value if the array element == the expected value.

public static T CompareExchange<T>(this T[] array, long index, T update, T comparand)

Atomically sets array element to the given updated value if the array element == the expected value.

public static T GetAndAccumulate<T>(ref T value, 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 static T GetAndAccumulate<T>(ref T value, 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 static T GetAndAccumulate<T>(this T[] array, long index, T x, Func<T, T, T> accumulator)

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

public static T GetAndAccumulate<T>(this T[] array, long index, T x, ref ValueFunc accumulator)

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

public static T GetAndSet<T>(this T[] array, long index, T update)

Modifies the array element atomically.

public static T GetAndUpdate<T>(ref T value, Func<T, T> updater)

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

public static T GetAndUpdate<T>(ref T value, ref ValueFunc updater)

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

public static T GetAndUpdate<T>(this T[] array, long index, Func<T, T> updater)

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

public static T GetAndUpdate<T>(this T[] array, long index, ref ValueFunc updater)

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

public static T SetAndGet<T>(this T[] array, long index, T update)

Modifies the array element atomically.

public static T UpdateAndGet<T>(ref T value, Func<T, T> updater)

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

public static T UpdateAndGet<T>(ref T value, ref ValueFunc updater)

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

public static T UpdateAndGet<T>(this T[] array, long index, Func<T, T> updater)

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

public static T UpdateAndGet<T>(this T[] array, long index, ref ValueFunc updater)

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

public static T VolatileRead<T>(this T[] array, long index)

Performs volatile read of the array element.

public static void VolatileWrite<T>(this T[] array, long index, T element)

Performs volatile write to the array element.